Multiple inheritance in C++ OOP, Example and syntax of multiple inheritance
In this tutorial, we will learn about the followings;
- Multiple inheritance in C++ OOP
- Example Multiple inheritance in C++ OOP
- The syntax of multiple inheritance
What is Multiple inheritance in C++ OOP?
In multiple inheritance, child class is derived from more than one parent class.
Syntax of multiple inheritance in C++ OOP
|1||class child_class_name :Access_specifier 1st_parent, |
|3||Body of the class;|
Example of multiple inheritance in C++ OOP
using namespace std;
class show : public sum1, public sum2
Line 11 shows multiple inheritance where child class” show” have two parents “sum1” and “sum2”.
Child class “Show” behaviour is as follows;
- show inherits variable n1 from sum1
- Show inherits variable n2 from sum2
|Test Your Understandings|
1.class show : public sum1, public sum2, here sum1 and sum2 are child classes of class sum1? YES / NO
2.Multiple inheritance means one class having more than one parents? YES / NO.