----------友元friend
文章平均质量分 50
寂寂寂寂寂蝶丶
这个作者很懒,什么都没留下…
展开
-
友元,全局函数、类成员函数作为友元函数
全局函数、类成员函数 作为友元函数#include "stdafx.h"#include using namespace std;#if 0同类对象间无私处异类对象间有友员//函数(可以是全局函数,也可是类成员函数)可以作友元,称为友元函数//友元的位置在类中哪个位置都可以 可以在private也可以在public----前向声明(forward declarati原创 2017-12-07 16:34:28 · 1917 阅读 · 0 评论 -
利用友元求坐标俩点之间的距离
全局函数作友元#include "stdafx.h"#include using namespace std;#include class Point{public: Point(float x, float y) :_x(x), _y(y){} friend float getDistance(Point &one, Point &another);private:转载 2017-12-07 16:37:35 · 571 阅读 · 0 评论 -
友元类
友元类#include "stdafx.h"#include using namespace std;//把一个类作为另一个类的友元,友元类//把PointManagement声明为Point的友元,Point的对象就可以//在PointManagement的类(或者函数)中访问Point的private数据成员class Point{public: Point(do原创 2017-12-07 16:38:50 · 314 阅读 · 0 评论