
Inheritance
Inheritance is probably the most powerful feature of object oriented programming. Inheritance is the technique that is used to build new classes from existing ones. In inheritance, you derive a new class from an existing class. The class from which you derive is called the base class, and the new class is called the derived class.
Public Derivation
In a public derivation, the derived class inherits public members as public, and protected members as protected. They can be accessed by a new member function of the derived class. However, instances of the derived classes may access only the public members.
Protected Derivation
In a protected derivation, the derived class inherits public and protected members as protected. They can be accessed by a new member function of the derived class. However, instances of the derived classes may access only the public members.
Private Derivation
In a private derivation, the derived class inherits public and protected members as private. They can be accessed by a new member function of the derived class. However, instances of the derived classes may not access them. Also, public and protected members of the base class are not available for subsequent derivations.
Regardless of the type of derivation, private members ( of base class ) are not accessible in the derived class. If these members are to be accessed, that can only be done by the methods of the base class.