C++大学基础教程_10_4_friend函数和friend类
来源:互联网 发布:windows桌面壁纸消失 编辑:程序博客网 时间:2024/06/06 01:34
//testMain.cpp#include <iostream>using namespace std;class Count{//使用非friend函数来修改private成员是错误尝试//用friend函数修改类的private数据friend void setX(Count &,int);public:Count():x(0){}//函数体为空void print() const{cout << x << endl;}private:int x;};void setX(Count &c,int val){c.x = val;}int main(){Count counter;cout << "counter.x after instantiation: " ;counter.print();setX(counter,8);cout << "counter.x after call to setX friend function: ";counter.print();system("pause >> cout");return 0;}
0 0
- C++大学基础教程_10_4_friend函数和friend类
- C++:友元函数friend
- [C++]friend友元类-友元函数
- friend 函数
- friend函数
- C++大学基础教程_10_10_代理类
- [C++]friend
- c++的inline和friend函数
- friend之友元函数和友元类
- 友元friend和继承(C++)
- C++大学基础教程_10_67_new和delete和static
- C++类的友元函数friend
- friend 函数在类中的用法
- C++大学基础教程 _10_3_组成:对象作为类的成员
- C++大学基础教程_11_8_实例研究:Array类
- C++大学基础教程_11_10_实例研究:String类
- C++三种构造函数以及explicit和friend关键字
- C++之friend友元类和友元函数
- 游戏提交已14天,状态仍是waiting for review,谁比我更惨
- 【节操】编译器手工开栈
- Cocos2d-x提出了自己的多分辨率支持方案
- Mockito-入门
- 逆向分析常用断点
- C++大学基础教程_10_4_friend函数和friend类
- mysql自增字段重排
- Oracle 无返回值的存储过程
- [每日一个小技巧] CentOS 下使用yum安装一类软件包
- servlet的url-pattern的配置
- C++大学基础教程_10_5_使用this指针
- 开一个博客,from here....
- C语言 投票问题
- 使用fastcgi_cache加速你的Nginx网站