#include<iostream.h>
#include<conio.h>
class base
{
private:
int a;
public:
{
a=x;
}
void displayb()
{
cout<<"\n base value is="<<a;
}
} ;
{
private:
int b;
public:
void getdatad(int y)
{
b=y;
}
void displayd()
{
cout<<"\n derive value is="<<b;
}
} ;
class derive1 : public base, public derive // Multiple Inheritence
{
private:
int c;
public:
{
c=z;
}
void displayd1()
{
cout<<"\n derive1 value is="<<c;
}
} ;
main()
{
clrscr();
derive1 d1;
d1.getdatab(5);
d1.getdatad(7);
d1.getdatad1(9);
d1.displayb();
d1.displayd();
d1.displayd1();
getch();
}
--------------------------------------------------------------------------------------
Define Multiple Inheritance
Deriving directly from more than one class is usually called multiple inheritance. Since it's widely believed that this concept complicates the design and debuggers can have a hard time with it, multiple inheritance can be a controversial topic. However, multiple inheritance is an important feature in C++ and C++ programmers think of it as a very good structuring tool.
No comments:
Post a Comment