You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
590 B
38 lines
590 B
16 years ago
|
/* File : example.h */
|
||
|
|
||
9 years ago
|
class Shape
|
||
|
{
|
||
16 years ago
|
public:
|
||
9 years ago
|
Shape() { nshapes++; }
|
||
|
virtual ~Shape() { nshapes--; };
|
||
|
double x, y;
|
||
|
void move(double dx, double dy);
|
||
16 years ago
|
virtual double area(void) = 0;
|
||
|
virtual double perimeter(void) = 0;
|
||
9 years ago
|
static int nshapes;
|
||
16 years ago
|
};
|
||
|
|
||
9 years ago
|
class Circle : public Shape
|
||
|
{
|
||
16 years ago
|
private:
|
||
|
double radius;
|
||
9 years ago
|
|
||
16 years ago
|
public:
|
||
9 years ago
|
Circle(double r)
|
||
|
: radius(r){};
|
||
16 years ago
|
virtual double area(void);
|
||
|
virtual double perimeter(void);
|
||
|
};
|
||
|
|
||
9 years ago
|
class Square : public Shape
|
||
|
{
|
||
16 years ago
|
private:
|
||
|
double width;
|
||
9 years ago
|
|
||
16 years ago
|
public:
|
||
9 years ago
|
Square(double w)
|
||
|
: width(w){};
|
||
16 years ago
|
virtual double area(void);
|
||
|
virtual double perimeter(void);
|
||
|
};
|