#include
#include
class shape
{
protected:
float x,y;
public:
void getdata()
{
cout<<"enter x &
y:"<
cin>>x>>y;
}
virtual void display();
/* {
cout<<"display
area"<
}*/
};
class triangle:protected shape
{
float area;
public:
void area1()
{
area=(1/2)*x*y;
}
void display()
{
cout<<"area of triangle="<
}
};
class rectangle:protected shape
{
float area;
public:
void area1()
{
area=x*y;
}
void display()
{
cout<<"area of rectangle="<
}
};
void main()
{
clrscr();
shape s;
triangle t;
rectangle r;
shape *sptr;
sptr=&s;
sptr->getdata();
sptr->display();
sptr=&t;
sptr->display();
t.area1();
sptr=&r;
sptr->display();
r.area1();
getch();
}
Copyright © 2011 - All Rights Reserved - Softron.in
Template by Softron Technology