[求助]友元函数的应用
#include <iostream.h>#include <math.h>
class point
{
public:
point (double xx, double yy) {x = xx ; y = yy; }
void Getxy () ; \\这里的G一定要大写么
friend double distance (point &a, point &b) ;
private:
double x , y ;
};
void point : : Getxy()
{
cout <<" ( "<< x << " , " << y << " ) " ;
}
double distance (point &a , point &b)
{
double dx = a.x - b.x ;
double dy = a.y - b.y ;
return sqrt (dx * dx + dy * dy) ;
}
int main()
{
point pl ( 3.0 , 4.0 ) , p2 (6.0 , 8.0) ;
p1. Getxy () ;
p2 .Getxy();
double d = distance (p1 ,p2 );
cout << "两点之间的距离是:" << d;
return 0 ;
}
请问上段代码的调用顺序是什么