#include <iostream>
#include<cmath>
using namespace std;
class CPoint
{
private:
double x; // 横坐标
double y; // 纵坐标
public:
CPoint(double xx=0,double yy=0):x(xx),y(yy){}
double distanc(CPoint &c);
friend double distan(CPoint &c1,CPoint &c2);
double getx()
{
return x;
}
double gety()
{
return y;
}
};
double dist(CPoint &c1,CPoint &c2)
{
return sqrt((c1.getx()-c2.getx())*(c1.getx()-c2.getx())+(c1.gety()-c2.gety())*(c1.gety()-c2.gety()));
}
double distan(CPoint &c1,CPoint &c2)
{
return sqrt((c1.x-c2.x)*(c1.x-c2.x)+(c1.y-c2.y)*(c1.y-c2.y));
}
double CPoint::distanc(CPoint &c)
{
return sqrt((this->x-c.getx())*(this->x-c.getx())+(this->y-c.gety())*(this->y-c.gety()));
}
int main()
{
double x1,y1,x2,y2;
cout<<"请输入第一个点的坐标"<<endl;
cin>>x1>>y1;
CPoint c1(x1,y1);
cout<<"请输入第二个点的坐标"<<endl;
cin>>x2>>y2;
CPoint c2(x2,y2);
cout<<"友元求距离;"<<distan(c1,c2)<<endl;
cout<<"一般函数求距离:"<<dist(c1,c2)<<endl;
cout<<"成员函数求距离:"<<c1.distanc(c2)<<endl;
return 0;
}