Explain the different types of inheritance

Estudies4you
Explain the different types of inheritance

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,define Inheritance,use of Inheritance,list out Inheritance in c++,Explain the different types of inheritance,Single inheritance,Multiple inheritance,Multi-level inheritance,Hierarchical inheritance,Hybrid inheritance,Multi-path inheritance,varaka kiran kumar,estudies4you,c++ lecture notes,c++ notes,jntuh c++ notes,jntu c++ notes
The root of this hierarchy i.e., the ‘Animals’ class is the most general base class. The carnivores, herbivores and omnivores classes are derived from this base class. Moreover, the carnivores class is the base class for the derived classes lion, tiger and jackal. The ‘Herbivores’ class is the base class for the derived classes, goat and sheep. The ‘Omnivores’ class is the base class for the derived classes bear and man.

Types of Inheritance
C++ supports six types of inheritance. They are,
1.       Single inheritance
2.       Multiple inheritance
3.       Multi-level inheritance
4.       Hierarchical inheritance
5.       Hybrid inheritance and
6.       Multi-path inheritance
To Top