Category: Private and Public Inheritance in C++

Interested in learning C Programming? Click here...


Single Inheritance-Private Inheritance in Cpp 0

Single Inheritance – Private Inheritance in C++

Let us understand what does private inheritance mean… Consider a simple example to illustrate the single inheritance. The Program given below shows a base class B and a derived class D. The class B contains one private data member, one public data member and three public member functions. The class D contains one private data member and two public member functions.

In private derivation, the public members of the base class becomes private members of the derived class. Therefore, the objects of the derived class D cannot have direct access to the public member functions of the base class...

Single Inheritance - Public Inheritance in Cpp 2

Single Inheritance – Public Inheritance in C++

Inheritance in which the derived class is derived from only one base class is called single inheritance. Let us consider a simple example to illustrate the single inheritance. Program given below shows a base class B and a derived class D. The class B contains one private data member, one public data member and three public member functions. The class D contains one private data member and two public member functions.

Given below is the output of the above program:

In the above program, following things require to be noted: The class D is a public derivation of...