main函数你自己写个吧 有什么问题可以给我留言
#include
2 using namespace std;
3 //通用类型定义用枚举实现比较好
4 enum which_shape{triangle,rectangle};
5 class shape
6 {
7 public:
8 virtual area();
9 shape(which_shape type);
10 virtual shape();
11 virtual void print_area();
12 private:
13 int shape_type;
14 };
15 class triangle :public shape
16 {
17 public:
18 virtual triangle(int ,int)
19 virtual int area()const
20 {
21 tri_area = bottom * height / 2;
22 return tri_area;
23 }
24 virtual void print_area()const
25 {
26 cout