
----------友元friend
文章平均质量分 50
寂寂寂寂寂蝶丶
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
友元,全局函数、类成员函数作为友元函数
全局函数、类成员函数 作为友元函数 #include "stdafx.h" #include using namespace std; #if 0 同类对象间无私处 异类对象间有友员 //函数(可以是全局函数,也可是类成员函数)可以作友元,称为友元函数 //友元的位置在类中哪个位置都可以 可以在private也可以在public ----前向声明(forward declarati原创 2017-12-07 16:34:28 · 2166 阅读 · 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 · 634 阅读 · 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 · 378 阅读 · 0 评论