( 12 ) “ 图形 ” 类 Shape 中定义了纯虚函数 CalArea() ,“ 三角形 ” 类 Triangle 继承了类Shape ,请 将
Triangle 类中的 CalArea 函数补充完整。
class Shape{
public:
virtual int CalArea()=0;
}
class Triangle: public Shape{
public:
Triangle{int s, int h}: side(s),height(h) {}
【 12 】 { return side*height/2 ; }
private:
int side;
int height;
};