#include
<
iostream.h
>
class Graph
... {
public:
double GetArea()
...{
return 0;
}
double GetPerimeter()
...{
return 0;
}
} ;
class Circle : public Graph
... {
double r;
public:
Circle()
...{
r=5.6;
}
double GetArea()
...{
return 3.1415*r*r;
}
double GetPerimeter()
...{
return 2*3.1415*r;
}
} ;
class Rect : public Graph
... {
double l,w;
public:
Rect()
...{
l=3;
w=4;
}
double GetArea()
...{
return l*w;
}
double GetPerimeter()
...{
return 2*l*w;
}
} ;
class Square : public Rect
... {
double l;
public:
Square()
...{
l=8;
}
double GetArea()
...{
return l*l;
}
double GetPerimeter()
...{
return 4*l;
}
} ;
void main()
... {
Graph *p;
Circle cir;
p=○
cout<<"The Area of the circle="<<p->GetArea()<<endl;
cout<<"The perimeter of the circle="<<p->GetPerimeter()<<endl;
Rect rect;
p=▭
cout<<"The area of the rectangle="<<p->GetArea()<<endl;
cout<<"the perimeter of the rectangle="<<p->GetPerimeter()<<endl;
Square sq;
p=&sq;
cout<<"The area of the square="<<p->GetArea()<<endl;
cout<<"The perimeter of the square="<<p->GetPerimeter()<<endl;
}
class Graph
... {
public:
double GetArea()
...{
return 0;
}
double GetPerimeter()
...{
return 0;
}
} ;
class Circle : public Graph
... {
double r;
public:
Circle()
...{
r=5.6;
}
double GetArea()
...{
return 3.1415*r*r;
}
double GetPerimeter()
...{
return 2*3.1415*r;
}
} ;
class Rect : public Graph
... {
double l,w;
public:
Rect()
...{
l=3;
w=4;
}
double GetArea()
...{
return l*w;
}
double GetPerimeter()
...{
return 2*l*w;
}
} ;
class Square : public Rect
... {
double l;
public:
Square()
...{
l=8;
}
double GetArea()
...{
return l*l;
}
double GetPerimeter()
...{
return 4*l;
}
} ;
void main()
... {
Graph *p;
Circle cir;
p=○
cout<<"The Area of the circle="<<p->GetArea()<<endl;
cout<<"The perimeter of the circle="<<p->GetPerimeter()<<endl;
Rect rect;
p=▭
cout<<"The area of the rectangle="<<p->GetArea()<<endl;
cout<<"the perimeter of the rectangle="<<p->GetPerimeter()<<endl;
Square sq;
p=&sq;
cout<<"The area of the square="<<p->GetArea()<<endl;
cout<<"The perimeter of the square="<<p->GetPerimeter()<<endl;
}