0
这是我的基类:对象是不允许
class Shape{
public:
Shape(){}
virtual double computeArea()=0;
virtual void expand(int f)=0'
virtual void display()=0;
}
这是我的子类:
class Rectangle : public Shape{
protected:
double width;
double height;
public:
Rectangle(){width = 0; length = 0;}
Rectangle(double w, double l){width = w; length = l}
double computeArea(){//code}
void expand(int f){//code}
void display(){//code}
}
然后,在主我试着这样做:
Shape * s = new Rectangle();
而且我不断收到“抽象类类型的对象”不允许使用“矩形” 我很舒服我超载了功能正确...请帮助。
矩形(double w,double l){width = w;长度= 1} 缺少';'在长度= 1 – DBug
和0'之后应该是0; –
此外,virtual void expand(int f)= 0',将单引号替换为'/';' – DBug