#include <iostream>
using namespace std;
class Shape
{
protected:
int w, h;
public:
Shape(int w=0, int h=0):w(w), h(h){}
};
class Rectangle:public Shape
{
public:
int h,w;
double area;
Rectangle(int n,int m){
h=n;
w=m;
}
double GetArea(){
area=h*w;
return area;
}
};
class Triangle:public Shape
{
public:
int h,w;
double area;
Triangle(int n,int m){
h=n;
w=m;
}
double GetArea(){
area=(h*w)/2;
return area;
}
};
int main()
{
int w, h;
cin >> w >> h;
Rectangle a(w , h);
cout << a.area() << endl;
cin >> w >> h;
Triangle b(w, h);
cout << b.area() << endl;
return 0;
}
main函数中出现编译错误,请教大神,如何更改?