Skip to content

Latest commit

 

History

History
 
 

Inheritance(C++)

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Inheritance

Inheritance is where derived class inherits the members (variables and functions) of base class.

The benefit of inheritance is that the derived class does not have to redeclare all the members which it inherits from the base class. Hence, reusability is achieved which makes the code cleaner.

Types of Inheritance

We have five types of Inheritance. Namely,

  1. Single Inheritance

    In this type of inheritance one derived class inherits from only one base class. It is the most simplest form of Inheritance.

    Single Inheritance

  2. Multiple Inheritance

    In this type of inheritance a single derived class may inherit from two or more than two base classes.

    Multiple Inheritance

  3. Hierarchical Inheritance

    In this type of inheritance, multiple derived classes inherits from a single base class.

    Hierarchical Inheritance

  4. Multilevel Inheritance

    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.

    Multilevel Inheritance

  5. Hybrid Inheritance

    The method of combining any two or more forms of inheritance in single form is called Hybrid Inheritance.

    Hybrid Inheritance