#include
#include
usingnamespacestd;
classPoint//Point类定义
{
public://外部接口
Point(intxx=0,intyy=0){X=xx;Y=yy;}
intGetX(){returnX;}
intGetY(){returnY;}
friendfloatfDist(Point&a,Point&b);//友元函数声明
private://私有数据成员
intX,Y;
};
floatfDist(Point&p1,Point&p2)//友元函数实现
{doublex=double(p1.X-p2.X);//通过对象访问私有数据成员
doubley=double(p1.Y-p2.Y);
returnfloat(sqrt(x*x+y*y));
}
voidmain()//主函数
{
Pointmyp1(1,1),myp2(4,5);//定义Point类的对象
cout