C++ Multiple Inheritance

If a class is derived from two or more base classes then it is called multiple inheritance. In C++ multiple inheritance a derived class has more than one base class.

How does multiple inheritance differ from multilevel inheritance?

Though but multiple and multilevel sounds like same but they differ hugely in meaning. In multilevel inheritance, we have multiple parent classes whereas in in multiple inheritance we have multiple base classes.

To put it in simple words, in multilevel inheritance, a class is derived from a class which is also derived from another base class. And these levels of inheritance can be extended. On the contrary, in multiple inheritance, a class is derived from two different base classes.

For example

Multilevel inheritance : Inheritance of characters by a child from father and father inheriting characters from his father (grandfather)

Multiple inheritance : Inheritance of characters by a child from mother and father

C++ Multiple Inheritance Block Diagram

Following block diagram highlights its structure.

As shown in above block diagram, class C is derived from two base classes A and B.

As in other inheritance, based on the visibility mode used or access specifier used while deriving, the properties of the base class are derived. Access specifier can be private, protected or public.

In the above program, there are two base class A and B from which class C is inherited. Therefore, derived class C inherits all the public members of A and B and retains their visibility. Here, we have created the object obj1 of derived class C.

Related Articles:

C++ Hierarchical Inheritance When several classes are derived from common base class it is called hierarchical inheritance. In C++ hierarchical inheritance, the feature...

C++ Multilevel Inheritance If a class is derived from another derived class then it is called multilevel inheritance. So in C++ multilevel inheritance,...

C++ Single Inheritance If a single class is derived from one base class then it is called single inheritance. In C++ single inheritance...

C++ Hybrid Inheritance The inheritance in which the derivation of a class involves more than one form of any inheritance is called hybrid inheritance....