hardkeyboard_boy 2020-04-02 13:00 采纳率: 0%
浏览 662

missing storage-class or type specifiers问题,大佬请进

#include
using namespace std;
class Point
{public:
Point(double a=0,double b=0) { x=a;y=b;}
virtual double Area()
{ cout<<"Call Point's Area function."<<endl;
return 0.0;
}
protected:
double x,y;
};

class RightTriangle:public Point
{public:
RightTriangle(double a=0,double b=0,double c=0,double d=0):Point(a,b)
{x1=c;y1=d;}
double Area()
{cout<<"Call RightTriangle's Area function."<<endl;
return ((x1-x)*(y1-y))/2;
}
protected:
double x1,y1;
};

class Circle:public Point
{public:
Circle(double a=0,double b=0,double u=0,double i=0,double r=0):Point(a,b)
{x2=u,y2=i;r=sqrt(pow((x2-x),2)+pow((y2-y),2));}
double Area()
{cout<<"Call Circle's Area function."<<endl;
return 3.14*r*r;
}
protected:
double x2,y2;r;
};

double CalcArea(Point &men) { return (men.Area());}
int main()
{
Point p(0,0);
RightTriangle r(0,0,2,2);
Circle c(0,0,1,2);
cout<<CalcArea(p)<<endl;
cout<<CalcArea(r)<<endl;
cout<<CalcArea(c)<<endl;
return 0;
}

最终有一个这个问题error C2501: 'r' : missing storage-class or type specifiers,搜得满身大汗都没搞懂到底怎么修改这个错误还请大佬解答萌新跪谢~~

  • 写回答

1条回答 默认 最新

  • 小学狗喵喵叫 2020-04-02 13:48
    关注

    分号改成逗号
    protected:
    double x2,y2,r;

    评论

报告相同问题?

悬赏问题

  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp