this指针测试
来源:互联网 发布:高铁票黄牛知乎 编辑:程序博客网 时间:2024/06/05 07:16
this指针变量记录的是当前对象的内存地址,即this指针指向当前的对象。
参考 http://blog.csdn.net/alohaha11/article/details/8770977
#include<iostream>#include<stdlib.h>using namespace std;class A{public: int get() const{return i;} void set(int x){ this->i=x;cout<<"this 指针保存的内存地址为:"<<this<<endl; }private: int i;};int main(){ A a; a.set(9); cout<<"对象a所在的内存地址"<<&a<<endl; cout<< "对象a所保存的值"<<a.get()<<endl; cout<<endl; A b; b.set(99); cout<<"对象b所在的内存地址"<<&b<<endl; cout<<"对象b的值 :" <<b.get()<<endl; system("pause"); return 0; }
- this指针测试
- VC深入详解中的一个this指针小测试
- this指针
- this指针
- this指针
- this指针
- this指针
- this 指针
- this指针
- this指针----
- this指针
- this 指针
- This 指针
- this指针
- This指针
- this指针
- this指针
- this 指针
- ssh-copy-id command not found
- oracle导入导出单个表的办法
- 网关
- android service的好处
- [ freemark ] 你还在无休止的拼接html么?
- this指针测试
- 串口工作原理
- Effective Objective-C 2.0: Item 4: Prefer Typed Constants to Preprocessor #define
- 高性能CSS(四)
- Backbone 1.0.0 版 API _ Backbone.Model validate 解析
- asp.net(C#)利用QRCode生成二维码
- 文件对比工具beyond compare使用总结
- Backbone 1.0.0 版 API _ Collection、Model、View的关系
- 数字在排序数组中出现的次数