Program to demonstrate Multi Level Inheritance :-
#include<iostream.h>
#include<conio.h>
class base
{
int a;
public:
void base_get()
{
cout<<"\nEnter value for base class : ";
cin>>a;
}
void base_show()
{
cout<<"\nValue in base class : "<<a;
}
};
class intermediate:public base
{
int x;
public:
void intermediate_get()
{
cout<<"\nEnter value for intermediate class : ";
cin>>x;
}
void intermediate_show()
{
cout<<"\nValue in intermediate class : "<<x;
}
};
class derived:public intermediate
{
int m;
public:
void derived_get()
{
cout<<"\nEnter value for derived class : ";
cin>>m;
}
void derived_show()
{
cout<<"\nValue in derived class : "<<m;
}
};
void main()
{
derived d;
d.derived_get();
d.intermediate_get();
d.base_get();
d.derived_show();
d.intermediate_show();
d.base_show();
getch();
}
No comments:
Post a Comment