#include
#include
class Point
{
private:
float x, y;
public:
Point(float xx, float yy)
{ x=xx; y=yy; }
float GetX(){ return x; }
float GetY(){ return y; }
friend float distance(Point&, Point&);
};
float distance(Point& a, Point& b)
{
float dx = a.x - b.x;
float dy = a.y - b.y;
cout<<"用友元函数 distance().显示两点的坐标 : \n ";
cout<
}
void main()
{
float d;
Point p1(10.5, 20.5), p2(2.5, 6.5);
d=distance(p1, p2);
cout<<" 两点的距离 : d = "<
C++忘得差不多了,要做的话还要看书。
哎,再加点分,我就更有动力了。