Inheritance is a way through which you can use the properties of an existing class into a new class. Similarly, In Multilevel inheritance, a class is derived from another derived class.

Example: ‘Monthly Average Saving Account’ is a ‘Saving Account’ and a ‘Saving Account’ is an ‘Account’ in a bank i.e the properties of Account is used in Saving Account and the properties of Saving Account is used in Monthly Average Saving Account.

Therefore, we can say that is a ‘Monthly Average Saving Account’ is an ‘Account’.

In multilevel inheritance, a class can have more than one parent class.

If we consider all types of bank accounts as classes in C++, then we can say that Monthly Average Saving Account has two parent class:

  1. Account
  2. Saving Account

C++ Multilevel Inheritance Block Diagram

Here we are assuming three levels, it can be bigger.

C++ Multiple Inheritance Block Diagram

Here, Derived Class II can use all properties of both Derived Class I and Base Class.

C++ Syntax for Multilevel Inheritance

Example of Multilevel Inheritance in C++

Tip: We have constructor overloading in our program.


Example of Multilevel Inheritance

That’s all we need to know for multilevel inheritance. If you have any doubts then do comment below.

Leave a Reply

five × 5 =