回覆列表
  • 1 # 使用者1158134898603

    class Shape

    {

    public:

    virtual double GetArea()=0;

    };

    class Rectangle : public Shape

    {

    public:

    Rectangle(double h, double w) : height(h), width(w){}

    double GetArea(){ return height * width; }

    private:

    double height;

    double width;

    };

    class Circle : public Shape

    {

    public:

    Circle(double r):radius(r){}

    double GetArea(){ return 3.14159 * radius * radius; }

    private:

    double radius;

    };

    class Square : public Rectangle

    {

    public:

    Square(double l) : Rectangle(l, l){}

    };

  • 中秋節和大豐收的關聯?
  • 蜂蜜和海鮮可以同食嗎?