Multiple Inheritance - OOP's Concept

What is Multiple Inheritance OOP's concept in C++?


Multiple Inheritance is a method by which a class is derived from more than one base class.

Example :

#include <iostream.h> using namespace std; class Square
int l;
void set_values (int x)
{ l=x;}
}; class CShow
void show(int i);
void CShow::show (int i)
cout << "The area of the square is::" << i << endl;
class Area: public Square, public CShow
int area()
{ return (l *l); }
}; int main ()
Area r;
r.set_values (5);;
return 0; }

Result :

The area of the square is:: 25

In the above example the derived class "Area" is derived from two base classes "Square" and "CShow". This is the multiple inheritance OOP's concept in C++.

C++ Tutorial

Ask Questions

Ask Question