Types of Inheritance in C++

Types of Inheritance in C++ image

Inheritance Types

On this page we will discuss about different types of inheritance in C++.The capability of a class to drive properties and characterstics from another class is called inheritance.Inheritance and its types is very important to understand the working of object oriented programming.

Types of Inheritance in C++

Interitance is a proces in which one object acquires all the properties and behaviour of it’s parent object automatically.Inheritance is of 5 types:

  • Single inheritance.
  • Multi-level inheritance.
  • Multiple inheritance.
  • Hierarchical Inheritance.
  • Hybrid Inheritance.
Types of Inheritance in C++ img

Single Level Inheritance

In such type of inheritance,  the derived class can only inherit from one base class.

Example – In the image, B(Derived Class) is only inheriting from A (One Base Class)

Single Level Inheritance

MultiLevel Inheritance

In MultiLevel Inheritance, a derived class is inherited from a base class, which in turn is derived from another base class.

Example – In our Example C is derived Class inheriting from B (Base Class to C), which in turn is also a derived Class inheriting from Class A (Base Class to B).

Here Class B  Acts has base class to Class C and itself is derived class in relationship with Class A.

MultiLevel Inheritance

Multiple Inheritance

In Multiple Inheritance, A derived Class can have more than 1 Base Classes, thus it is deriving properties from various base Classes.

Example – In the image, B is a derived class which is deriving its properties from 3 different base classes, A1, A2 and A3.

Multiple Inheritance

Hierarchical Inheritance

It in some terms is opposite of Multiple inheritance. Here a Base Class is parent to various Derived Classes.

Example – In our example, A acts as Base Class to B1, B2 and B3, which all are derived classes of A.

Hierarchical Inheritance

Hybrid Inheritance

This is essentially a combination of one or more types of inheritance. 

For Example – Multiple and Hierarchical inheritance combination. 

Hybrid Inheritance

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription