Multiple Inheritance In C++ With Example
Multiple Inheritance ?
When a class is derived from two or more base classes, such inheritance is called Multiple Inheritance.

Multiple inheritance occurs when a class inherits from more than one base class.The class which inherits the properties of another class is called Derived or Child or Sub class and the class whose properties are inherited is called Base or Parent or Super class
Syntax:
Example 1:
Output :
x: 11 value of a: 100 value of b: 200 value of c: 300
Example 2:
#include <iostream> #include<conio.h> class student { protected: int rno, m1, m2; public: void get() { cout << "Enter the Roll no :"; cin>>rno; cout << "Enter the two marks :"; cin >> m1>>m2; } }; class sports { protected: int sm;// sm = Sports mark public: void getsm() { cout << "\nEnter the sports mark :"; cin>>sm; } }; class statement : public student, public sports { int tot, avg; public: void display() { tot = (m1 + m2 + sm); avg = tot / 3; cout << "\n\n\tRoll No : " << rno << "\n\tTotal : " << tot; cout << "\n\tAverage : " << avg; } }; void main() { clrscr(); statement obj; obj.get(); obj.getsm(); obj.display(); getch(); }
Output :
x: 10 Enter the Roll no: 100 Enter two marks 90 80 Enter the Sports Mark: 90 Roll No: 100 Total : 260 Average: 86.66