Multi level inheritance in C++ with Syntax and Examples

By: Prof. Fazal Rehman Shamil
Last modified on August 27th, 2020

Multilevel inheritance in C++ OOP – Example program

In this tutorial we will learn about the followings;

  1. Multilevel inheritance in C++ OOP
  2.  Example of multi-level inheritance in C++ OOP
  3. The syntax of multi-level inheritance in C++ OOP
  4. The basic program of multi-level inheritance  in C++ OOP

What is Multi-level inheritance?

A derived class can be derived from another derived class. A child class can be the parent of another class.

Give an example of multilevel inheritance?

Class C is a child of class B and class B is child class of class A.

multivel child parent relationship of classes
Figure: multi-level inheritance.

What is the syntax of multilevel inheritance?

Basic Program of multi-level inheritance

Here in this example there is multi level inheritance because

  • Declaration of variable n1 is inherited from sum to child1 
  • Declaration of Variable n2 is inherited from chil1 to child2 
  • Child2 now uses one variable of its first parent and one variable of its grandfather.

So, this is a better example of multilevel inheritance.

Difference between multi level and multiple Inheritance in C++

Here, i am showing you a comparison of multiple and multi level inheritance in C++.

Multilevel Inheritance Multiple Inheritance
In Multilevel Inheritance parent shares inherits with child and then child becomes parent of other class and share the resources of parent to its child. In Multiple Inheritance a class inherits from more than one parent classes.

Class Levels

Multilevel Inheritance has three class levels namely, base class, intermediate class and derived class. Multiple Inheritance has two class levels namely, base class and derived class.


Multilevel Inheritance is widely used as compared to multiple inheritance. Multiple Inheritance is complex as compared to multi level inheritance and not widely used.


Exercise and Solution Multi level inheritance

  1. C++ program to print a hollow square or rectangle star pattern by achieving the multi-level inheritance.
  2. Multilevel inheritance C++ program to display the pattern like a pyramid.
  3. Multilevel inheritance C++ program to show the sum of an A.P. series.
  4. Multilevel inheritance C++ program to display patterns like the right angle.
  5. Multi-level inheritances C++ program to display the cube of the number up to a given integer.
  6. Multilevel inheritance C++ Program to convert a decimal number into binary.
  7. C++ program to find HCF using Multilevel inheritance.
  8. Develop a program in C++ to display the pattern like a pyramid using an asterisk * and each row contains an odd number of asterisks by using the Multilevel inheritance.
  9. Write a C++ program to print the rhombus star pattern of N rows using Multi-Level Inheritance.
  10. Write a program in C++ to convert a decimal number to hexadecimal using the Multi-Level Inheritance in object-oriented programming (OOP).
  11. Write a program in C++ to convert a decimal number into an octal without using an array using Multi-Level in object-oriented programming(OOP).
  12. C++ program to display Pascal’s triangle using the Multi-Level inheritance.
  13. Multi-Level inheritance C++ program to print hollow rhombus, parallelogram star pattern.
  14. Multi-Level Inheritance C++ program to print mirrored right triangle star pattern.
  15. Multi-level inheritance C++ Program to convert an octal number into binary.
  16. MultiLevel inheritance Floyd Triangle C++.
  17. C++ Program to display the sum of the series using Multilevel inheritance.
  18. MultiLevel Inheritance C++ program to find Strong Numbers within a range of numbers.
  19. Multilevel inheritance C+ Program Armstrong number of n digits.
  20. Multilevel inheritance C++ program to convert a decimal number into binary.
  21. Multilevel inheritance C++ to display the n terms of odd natural number and their sum.
  22. Multilevel inheritance C++ program pattern like a pyramid repeat.

Topic Covered

Multilevel inheritance in C++ OOP with example and program.

Prof. Fazal Rehman Shamil
Latest posts by Prof. Fazal Rehman Shamil (see all)