最近看了下欧丽奇《程序员面试宝典》,看到有个列子很好,就敲下来分给大家
#include "stdafx.h"
#include <iostream>using namespace std;
class point
{
float x, y;
public:
point(float a = 0.0f, float b = 0.0f) : x(a),y(b){};
friend float danstence(point left, point right);
};
{
return sqrt(((left.x - right.x)*(left.x - right.x) + (left.y - right.y)*(left.y - right.y)));
}
void main()
{
point tmp1(0,0);
point tmp2(3,4);
danstence(tmp1, tmp2);
return 0;
}