Friday, 7 September 2012

Multiple Inheritance mod(private) in C++

#include<iostream.h>
#include<conio.h>
class base1
{
protected:int a;
public:
void get_a()
{
cout<<"\n Enter the value for A:";
cin>>a;
}
};
class base2
{
protected:int b;
public:
void get_b()
{
cout<<"\n Enter the value for B:";
cin>>b;
}
};
class base3
{
protected:int c;
public:
void get_c()
{
cout<<"\n Enter the value for C:";
cin>>c;
}
};
class derived:private base1,private base2,private base3
{
public:
void show()
{
get_a();
get_b();
get_c();
cout<<"\n A="<<a;
cout<<"\n B="<<b;
cout<<"\n C="<<c;
}
};
void main()
{
derived obj;
clrscr();
cout<<"\n\t Multiple Inheritance:";
obj.show();
getch();
}

No comments:

Post a Comment

There was an error in this gadget