If a derived class is created from another derived class (intermediate base class) then such an inheritance is called multilevel inheritance.

Multilevel Inheritance

In the Multilevel Inheritance, there is one base class and another class that is derived from this base class is called the derived class.

The process continues to derive a new class from the derived class. The following is the schematic representation.

Class Student is the base class and class Test is the class derived from the class Student.

Again class Result is derived from class Test and hence again class Test is the base class and class Result is the derived class. Have a look at the following example.

As you can see, Student is the base class, Test is the derived class and Result is the newly derived class from the existing derived class.


using namespace std;
class Student{ 
protected: int marks;
public: void accept(){ 
cout<<" Enter marks"; 
cin>>marks; } };
class Test :public Student{ 
protected: int p=0;
public: void check(){ 
} } }; 
class Result :public Test{ 
public: void print(){ 
if(p==1) cout<<"n You have passed";
else cout<<"n You have not passed";
} }; 
int main(){ 
Result r; 
return 0; }

Output:-Enter marks 70
You have passed

Explanation of the program

As you can see there are three different classes that have been used such as the class Student, class Test, and class result.

Here the class student is inherited in class test whereas class Test is inherited in the class Result.

The members of class Students can be accessed by the other two classes. As we have created only one object for result class Result this means that we can access all members from the other two classes.

this is called multilevel inheritance.

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Comments to: Simple Program for Multilevel Inheritance in C++

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password