3.1.2. Different form of Inheritance, Defining the Base and Derived Classes, Access to the Base Class Members, Base and Derived Class Construction, Destructors
Q12. What is Inheritance? List and Explain the different types of inheritance.
Answer:
Inheritance
Inheritance is an object-oriented technique used for deriving the features of one class into another class. It allows to build a hierarchy of classes such that, starting from a most general class to a most specific class. The class which is inherited is called as a ‘base’ class or a ‘parent’ class and the class which inherits a base class is called as a ‘derived’ class or a ‘child class The base class contains features that are common to all objects that are derived from it. Whereas, the derived class includes its base class features as well as its own features. Moreover, the derived class may in turn become the base class and can be inherited by another derived class.
Example
Consider the following hierarchy,
Types of Inheritance
C++ supports six types of inheritance. They are,