#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]
第八行move(double a,double b),怎么改?
void move()
函数定义必须要有返回值