Loading....
Coupon Accepted Successfully!

 

Types of Inheritance

So far, we have learned examples of simple inheritance that use one base class and one derived class. The process of inheritance can be either simple or complex.
 
This depends on the following points:
  1. Number of base classes: The program can use one or more base classes to derive a single class.
  2. Nested derivation: The derived class can be used as a base class, and a new class can be derived from it. This can be possible at any extent.
Based on the above points, inheritance is classified as follows:
  1. Single Inheritance
  2. Multiple Inheritance
  3. Hierarchical Inheritance
  4. Multilevel Inheritance
  5. Hybrid Inheritance
  6. Multi-path Inheritance
The different types of inheritance are described in Figure: Types of inheritance. The base classes are at the top, and the derived classes are at the bottom. The arrow pointing from top to bottom indicates that the properties of the base class are inherited by the derived class and vice versa is not applicable.
  1. Single Inheritance
     
    This occurs when only one base class is used for the derivation of a derived class. Further, derived class is not used as a base class, such a type of inheritance that has one base and derived class is known as single inheritance. Figure: Types of inheritance (a) indicates single inheritance.
  2. Multiple Inheritance
     
    When two or more base classes are used for the derivation of a class, it is called multiple inheritance. Figure: Types of inheritance (b) indicates multiple inheritance.
  3. Hierarchical Inheritance
     
    When a single base class is used for the derivation of two or more classes, it is known as hierarchical inheritance. Figure: Types of inheritance (c) indicates hierarchical inheritance.
  4. Multilevel Inheritance
     
    When a class is derived from another derived class, that is, the derived class acts as a base class, such a type of inheritance is known as multilevel inheritance. Figure: Types of inheritance (d) indicates multilevel inheritance.
  5. Hybrid Inheritance
     
    A combination of one or more types of inheritance is known as hybrid inheritance. Figure (e) indicates hybrid inheritance.
  6. Multipath Inheritance
     
    When a class is derived from two or more classes, those are derived from the same base class. Such a type of inheritance is known as multipath inheritance. Figure: Types of inheritance (f) indicates multipath inheritance.

(a) Single Inheritance

 

(b) Multiple Inheritance

 

(c) Hierarchical Inheritance

 

(d) Multilevel Inheritance

 

(e) Hybrid Inheritance

 

(f) Multipath Inheritance

Fig: Types of inheritance





Test Your Skills Now!
Take a Quiz now
Reviewer Name