2004-04-30 20:17:06 +04:00
|
|
|
/* File : example.h */
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class Shape
|
|
|
|
{
|
2004-04-30 20:17:06 +04:00
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
Shape() { nshapes++; }
|
|
|
|
virtual ~Shape() { nshapes--; };
|
|
|
|
double x, y;
|
|
|
|
void move(double dx, double dy);
|
2004-04-30 20:17:06 +04:00
|
|
|
virtual double area(void) = 0;
|
|
|
|
virtual double perimeter(void) = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
static int nshapes;
|
2004-04-30 20:17:06 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class Circle : public Shape
|
|
|
|
{
|
2004-04-30 20:17:06 +04:00
|
|
|
private:
|
|
|
|
double radius;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2004-04-30 20:17:06 +04:00
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
Circle(double r)
|
|
|
|
: radius(r){};
|
2004-04-30 20:17:06 +04:00
|
|
|
virtual double area(void);
|
|
|
|
virtual double perimeter(void);
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class Square : public Shape
|
|
|
|
{
|
2004-04-30 20:17:06 +04:00
|
|
|
private:
|
|
|
|
double width;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2004-04-30 20:17:06 +04:00
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
Square(double w)
|
|
|
|
: width(w){};
|
2004-04-30 20:17:06 +04:00
|
|
|
virtual double area(void);
|
|
|
|
virtual double perimeter(void);
|
|
|
|
};
|