swig/Examples/c/class/example.h
Vadim Zeitlin 9a2e48b447 Clean up class example header
Apply changes of b115c984a (More cleaning up of the class examples,
2014-05-05) and other similar commits to the header in this branch too.
2022-01-04 01:32:25 +01:00

34 lines
574 B
C++

/* File : example.h */
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};