你写的代码发出来看看,帮你调试一下。
#include <iostream>
#include<math.h>
using namespace std;
class MyPoint
{
private:
double x;
double y;
public:
MyPoint()
{
x=0;
y=0;
}
MyPoint(double a,double b)
{
x=x;
y=y;
}
double get_x()
{
return x;
}
void set_x(double a)
{
x=a;
}
void set_y(double a)
{
y=a;
}
double get_y()
{
return y;
}
double distance(MyPoint a)
{
double b;
b=(x-a.get_x())*(x-a.get_x())+(y-a.get_y())*(y-a.get_y());
b=sqrt(b);
return b;
}
};
int main()
{
Point a;
Point b(10,30.5);
double c;
c=a.distance(b);
cout<<"***********Extend MyPoint**********"<<endl;
cout<<c;
cout<<endl;
return 0;
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!