概念的东西不讲了,直接上代码:
1.友元函数:
Point.类的声明与定义:
#pragma once
#ifndef _POINT_H
#define _POINT_H
class Point
{
public:
void getXY();
friend double distanceXY(Point &a,Point &b);
public:
Point(double x,double y);
~Point(void);
private:
double x;
double y;
};
#endif
#include "stdafx.h"
#include "Point.h"
#include<cmath>
#include<iostream>
using namespace std;
Point::Point(double x,double y)
{
this->x=x;
this->y=y;
}
Po......
阅读全文