徒手也一下 试一试
class Point{
};
class Circle:Point{
protected:
float r;
public:
Circle();
Circle(float r);
float getArea();
};
Circle::Circle(float r){
this -> r = r;
}
Circle::Circle(){
this -> r = 0;
}
floatCircle::getArea(){
returnPI*r*r;
}
class Ball :Circle{
public:
Ball(float r);
float getArea();
};
floatBall::getArea(){
return (PI/3)*r*r*r;
}
Ball::Ball(float r){
this -> r = r;
}
int main(){
Circle c = Circle(3);
cout << c.getArea() << endl;
Ball b = Ball(2);
cout << b.getArea();
return0;
}