#include
class shape
{
public:
virtual double area() const = 0;
};
class circle :
public shape
{
public:
double area() const {return 3.14 * radius * radius;};
circle(double r) : radius(r), shape()
{}
private:
double radius;
};
class rect :
public shape
{
public:
double area() const {return width * length;}
rect(double w, double l) : shape(), width(w), length(l){}
private:
double width, length;
};
int main()
{
shape* c1 = new circle(3.0);
std::cout << c1 -> area() << std::endl;
shape* r1 = new rect(3, 5);
std::cout << r1 -> area() << std::endl;
delete c1;
delete r1;
return 0;
}