class Point {
public:
double x, y;
};
class Distance {
public:
Point a, b;
double dist() {
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
};
class Circle :public Point {
public:
double r;
double area() {
return acos(-1.0)*r*r;
}
double circumference() {
return 2 * acos(-1.0)*r;
}
};
class Square :public Point {
public:
double a;
double area() {
return a*a;
}
double circumference() {
return 4 * a;
}
};
class Cylinder :public Circle, public Square {
public:
double surface() {
return 2 * Circle::area() + Square::area();
}
};
不知道为什么要用线段类来派生Circle和Square,我觉得用Point更好吧?
随便写写,不要在意细节