Types of Inheritance in C++

Inheritance Types in C++

Majorly there are 5 different types of classified Inheritance in C++, which are –

  • Single inheritance
  • Multiple Inheritance
  • Multilevel inheritance
  • Hierarchical Inheritance
  • Hybrid Inheritance
    • Also known as Virtual Inheritance
Types-Of-inheritence

Single Level Inheritance

In such type of inheritance,  the derived class can only inherit from one base class.

Example – In the image, B(Derived Class) is only inheriting from A (One Base Class)

Single level inheritence

MultiLevel Inheritance

In MultiLevel Inheritance, a derived class is inherited from a base class, which in turn is derived from another base class.

Example – In our Example C is derived Class inheriting from B (Base Class to C), which in turn is also a derived Class inheriting from Class A (Base Class to B).

Here Class B  Acts has base class to Class C and itself is derived class in relationship with Class A.

Multi level

Multiple Inheritance

In Multiple Inheritance, A derived Class can have more than 1 Base Classes, thus it is deriving properties from various base Classes.

Example – In the image, B is a derived class which is deriving its properties from 3 different base classes, A1, A2 and A3.

Multiple inheritance

Hierarchical Inheritance

It in some terms is opposite of Multiple inheritance. Here a Base Class is parent to various Derived Classes.

Example – In our example, A acts as Base Class to B1, B2 and B3, which all are derived classes of A.

Hierarchical Inheritance

Hybrid Inheritance

This is essentially a combination of one or more types of inheritance. 

For Example – Multiple and Hierarchical inheritance combination. 

Hybrid