Hierarchical Inheritance in C++

Inheritance is the process by which objects of one class acquire the properties of another class. By this we can add additional features to an existing class without modifying it.
This is possible by deriving a new class from the existing one. The new class will have combined features of both the classes.

Hierarchical Inheritance in C++

Hierarchical Inheritance in C++ is that in which a Base class has many sub classes or when a Base class is used or inherited by many sub classes. Thus when more than one classes are derived from a single base class, such inheritance is known as Hierarchical Inheritance, where features that are common in lower level are included in parent class.

Hierarchical Inheritance in C++

Example Program of Hierarchical Inheritance in C++

Run Online

Output
Total Objects: 1
The square value is:: 100
The cube value is::8000
Watch it on YouTube

Leave a Reply

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