m0_56310790 2021-03-19 21:34 采纳率: 0%
浏览 84

C++ forbids declaration of 'move' with no type

#include <iostream>
#include <cmath>
using namespace std;
class point
{
public:
double x,y;
move(double a,double b)
{x=a;
y=b;}

double getx()
	{
		return x;
	}
	double gety()
	{
		return y;
	}

double Distance(const point &p)
{
double dist;
dist=sqrt((p.x-x)*(p.x-x)+(p.y-y)*(p.y-y));
return dist;
}
};
int main()

{point a,b,c;
   a.move(7.8,9.8);

   b.move(34.5,67.8);

   c=a;

   cout<<"a和b两点之距为:"<<a.Distance(b)<<endl;

   cout<<"b和c两点之距为:"<<b.Distance(c)<<endl;

   cout<<"a和c两点之距为:"<<a.Distance(c)<<endl;

   c.move(26.7,58); //将c点的坐标移动到参数所指定的位置

   cout<<"c("<<c.getx()<<","<<c.gety()<<")"<<endl;//输出c点的坐标

return 0;
}

  [Error] ISO C++ forbids declaration of 'move' with no type [-fpermissive]

  • 写回答

3条回答 默认 最新

  • m0_56310790 2021-03-19 21:36
    关注

    第八行move(double a,double b),怎么改?

    评论

报告相同问题?