Multilevel Inheritance in C++

Inheritance in C++ is one of the key features of Object-oriented programming. It allows user to create a new class (derived class) from an existing class(base class). This makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and fast implementation time. An existing class that is “parent” of a new class is called a base class. New class that inherits properties of the base class is called a derived class. The idea of inheritance implements the is a relationship. For example, mammal IS-A animal, dog IS-A mammal hence dog IS-A animal as well and so on.

Multilevel Inheritance in C++

In this type of inheritance the derived class inherits from a class, which in turn inherits from some other class. The Super class for one, is sub class for the other. When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent classes, such inheritance is called Multilevel Inheritance. The level of inheritance can be extended to any number of level depending upon the relation. Multilevel inheritance is similar to relation between grandfather, father and child.

multilevel inheritance in c++

Syntax of Multilevel Inheritance in C++
Example of Multilevel Inheritance in C++

Run Online

Total Objects: 1
Value of a: 10
Value of b: 20
Value of c: 30
Watch it on YouTube

Leave a Reply

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