Multiple inheritance

Definition:

 

A class that inherit the attributes of more than one base class is known as multiple inheritance.Multiple inheritannce allows us to combine the features of several existing classes as a starting point for the deriving the new class.It is like a child inherting the physical features of one parent and intelligence of another.

 

 

Example:

 

Area,Perimeter are the base classesRectangle is the derived classes

 

Syntax:

 

The syntax of derived class with multiple base class is as follows

 

class D : visibility B-1, visibility B-2 ….
{

                ……………

                …………… (Body of D)

                ……………
};

 

where the visibility may be either public or private.The base classes are seperated by commas.

 

Example:

 

 

Class P: public M, public N

{

               public:

void display (void);

}

 

Classes M and N are the two bases classes,class P is the derived Classes.Class P inherit all the properties of class M,N and also it has a certain own new features

 

Inheritance types by s.kamatchi priyanka