#include
#include
class sqr
{
protected:
int x;
public:
virtual void getdata();
virtual void display();
virtual int area();
};
class rect :public sqr
{
protected:
int y;
public:
void getdata();
void display();
int area();
};
void sqr::getdata()
{
cout<>x;
}
void sqr::display()
{
int ar;
ar=area();
cout<<"n Value of One side : "<<x;
cout<<"n Value of another side : "<<x;
cout<<"n Area of the Square is : "<<ar;
}
int sqr::area()
{
int temp;
temp=x*x;
return(temp);
}
void rect::getdata()
{
cout<>x;
cout<>y;
}
void rect::display()
{
int ar;
ar=area();
cout<<"n Value of One side : "<<x;
cout<<"n Value of another side : "<<y;
cout<<"n Area of the rectangle is : "<<ar;
}
int rect::area()
{
int temp;
temp=x*y;
return(temp);
}
main()
{ int i;
sqr sob;
rect rob;
rect *ptr[2];
clrscr();
ptr[0]=(rect *)&sob;
ptr[1]=&rob;
for(i=0;igetdata();
ptr[i]->area();
ptr[i]->display();
}
getch();
}