Home >> Sem 2 >> C++ programs >> INHERIT
/* Write a program to define a inharitance of class from an existing class */
#include<iostream.h>
#include<conio.h>
class test
{
int a,b;
public :
void get(int p,int q)
{
a = p;
b = q;
}
void show()
{
cout<<"\nA : "<<a<<", B : "<<b;
}
};
class temp : public test
{
int x,y;
public:
void getdata(int p,int q)
{
x = p;
y = q;
}
void disp()
{
cout<<"\nX : "<<x<<", Y : "<<y;
}
};
void main()
{
int i,j;
test t1;
temp a1;
clrscr();
cout<<"Enter two integer values : ";
cin>>i>>j;
t1.get(i,j);
t1.show();
a1.getdata(i,j);
a1.get(i,j);
a1.show();
a1.disp();
getch();
}