C++ this指针
来源:互联网 发布:王用汲 知乎 编辑:程序博客网 时间:2024/06/07 11:03
经常看到this指针,看到也很蒙,最近看嵌入式软件的系统指针也用this指针表示,C++对象中有时也用到this指针,但是都没搞明白,今天看到百度知道有人问,看了几个答案才明白,大家参考一下:
防止命名冲突时,还有想将对象本身的指针或者引用给别的函数时 return this; // 返回对象本身的指针 return *this;
// 返回对象本身的引用 void a::fun() { this->x=x+1; //此处直接用x=x+1运行结果完全相同 }
这样没有命名冲突,定义个fun(int x)再试试吧
阅读全文
0 0
- 【C/C++】this指针
- C++this指针、智能指针
- 【C++】this 指针
- C++this指针
- C++this指针
- C++this指针
- C++this指针
- C++this指针
- c++this指针
- C++this指针
- C++this指针
- C++this指针(二)
- C++-this指针
- c++this指针
- C++this指针
- C ++的this指针
- C++this指针详解
- C++this指针
- MySQL使用数据处理函数和汇总数据.md
- git 配置
- 双向链表_双环
- Hello Kotlin(二)环境搭建
- C++的队列和pair
- C++ this指针
- Arduino(16MHz) timer mechanism
- setter方法注入与内部注入
- 在Eclipse环境下Tomcat的配置
- 《人月神话》的观点:是或非?
- 定积分的近似计算方法
- ConcurrentSkipListMap、ConcurrentSkipListSet源码解读
- 30天自制操作系统(第03天)–进入32位模式并引入C语言
- Redis集群原理简述