Friday, 7 September 2012

Hybrid Inheritance in C++

#include<iostream.h>
#include<conio.h>
class base
{
public:int a;
};
class intermediate1:public base
{
public:int b;
};
class intermediate2:public base
{
public:
int c;
};
class derived:public intermediate1,public intermediate2
{
public:
int d;
};
void main()
{
derived obj;
clrscr();
obj.intermediate1::a=10;
obj.b=20;
obj.c=30;
obj.d=40;
cout<<"\n\t Hybrid inheritance:\n";
cout<<"\n\t A value="<<obj.intermediate1::a;
cout<<"\n\t B value="<<obj.b;
cout<<"\n\t C value="<<obj.c;
cout<<"\n\t D value="<<obj.d;
getch();
}

No comments:

Post a Comment

There was an error in this gadget