3 types of inheritance
Recall that we have mainly used public inheritance in the class as this is the most commonly used form of inheritance. The public inheritance appears as follows:
class derived : public base { ... };
However, the inheritance can also be protected or private.
class derived : protected base { ... };
class derived : private base { ... };
Below are the effects of using public, protected, and private inheritances.
Public Inheritance
The public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class.
Protected Inheritance
The public and protected members of the base class become protected members of the derived class.
Private Inheritance
The public and protected members of the base class become private members of the derived class.