如题 ,测试代码如下

#include <iostream>

class thisPointer
{
public:

    thisPointer()
    {
        std::cout << this << std::endl;
    }

    ~thisPointer()
    {

    }
};
int main()
{
    thisPointer* thisPt = new thisPointer();
    std::cout << thisPt << std::endl;           //构造函数中输出的this指针和new 返回的指针一样,应该是class数据的首地址 
                                                //我猜这个首地址应该是由new决定的,然后指针指向函数或者属性的地址获取内容

    int a;
    std::cin >>a;

}

输出结果:

类中this指针介绍

 

 

相关文章:

  • 2022-12-23
  • 2021-09-23
  • 2021-12-29
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-06-06
相关资源
相似解决方案