Hierarchical inheritance

Hierarchical inheritance describes a situation in which a parent class is inherited by multiple subclasses. A type of inheritance in which more than one class is inherited from a single parent or base class is known as hierarchical inheritance.

The concept of inheritance is very similar to the real world. Just like a son inherits the properties (characteristics and behavior) of his father and father himself inherits the properties of the son's grandfather. In programming norms, inheritance occurs when one class inherits the properties of another class(base).
Here class A is the base class. Class B and Class C are the derived classes of A.
Class D and Class E are derived classes of B. Class F and Class G are derived classes of C. Thus forming the structure of hierarchical inheritance.

Where hierarchical inheritance does is used?
It is used in the following cases where hierarchy is to be maintained. For instance, the database of an organization is stored in the hierarchical format. There are different sections of an organization such as IT, computer science, Civil, Mechanical, etc. Each organization has the same attributes such as student name, roll number, year, etc. which comes under a class Student. Hence all the sections inherit the student properties and thus following the format of hierarchical inheritance.

Posted on by