c++ 定义一个抽象类CShape,包含纯虚函数 GetArea和纯虚函数SetData,然后派生出三角形CTriangle类、矩形

日期:2017-09-02 11:44:56 人气:1

c++ 定义一个抽象类CShape,包含纯虚函数 GetArea和纯虚函数SetData,然后派生出三角形CTriangle类、矩形

#include using namespace std;class CShape{public: virtual double GetArea()const=0; virtual void SetArea()=0;};class CTriangle:public CShape{private: double height; double bottom;public: double GetArea()const{ return 0.5 * height * bottom; } void SetArea(
    A+
热门评论