/*
*烟台大学计算机学院
*文件名称:xiangmu3.cpp
*作 者:李亚辉
*完成日期:2016年6月2日
*版 本 号:vc++6.0
*
*问题描述:
*输入描述:无
*程序输出:
*/
#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){}//构造函数
friend void dis(CPoint &,CPoint &);//友元函数,计算距离
};
void dis(CPoint &p1,CPoint &p2)//友元函数,计算距离
{
double c;
c=sqrt(p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
cout<<c<<endl;
}
int main()
{
CPoint a(1,2);
CPoint b(1,3);
::dis(a,b);
return 0;
}