Multi-path Inheritance

Estudies4you

6. Multi-path Inheritance

It refers to the process of deriving a class from two or more classes which is being derived from the base class.
Multi path Inheritance,define Multi path Inheritance,Multi path Inheritance definition,Multi path Inheritance notes,Multi path Inheritance lecture notes,Multi path Inheritance study material,explain Multi path Inheritance,discuss about Multi path Inheritance,estudies4you,types of inheritance,c++ lecture notes,c++ notes,c++ class room notes,c++ study material jntu,oops using c++ lecture notes,
Figure: Multipath Inheritance

Syntax
class Baseclass
{
private://Access specifiers
public:
void function()
{
//statements
}
};
class Derivedclass1: virtual public Baseclass
{
//statements
};
class Derivedclass2: virtual public Baseclass
{
//statements
};
class Derivedclass3: public Derivedclass2
{
public:
void function()
{
function();
}
};

Program
#include<iostream.h>
#include<conio.h> ,
class Base
{
protected:
int b;
};
class D1 : public virtual Base //declaration of virtual base‘class.
{
protected: :
int dl;  //declaration of member variable
};
class D2 : public virtual Base //declaration of virtual class
{
protected:
int d2;  //declaration of member variable
};
class D3 : public D1, D2 //declaration of virtual class
{
int d3; //declaration of member of variable
public:
void get() //declaration of member function D3.
{
cout<< “Give the input values for b,d1,d2 and d3 =”;
cin>>b>>d1>>d2>>d3;
}
void put()
{
cout<<“b=”<<b;
cout<<“\nd1=” <<d1;
cout<<“\nd2=” <<d2;
cout<<“\nd3=” <<d3;
}
};
int main()
{
clrscr();
D3 x;
x.get(); //data is read
x.put(); //data is displayed
getch();
return 0;
}
Output
Multi path Inheritance,define Multi path Inheritance,Multi path Inheritance definition,Multi path Inheritance notes,Multi path Inheritance lecture notes,Multi path Inheritance study material,explain Multi path Inheritance,discuss about Multi path Inheritance,estudies4you,types of inheritance,c++ lecture notes,c++ notes,c++ class room notes,c++ study material jntu,oops using c++ lecture notes,

To Top