相关疑难解决方法(0)

"this"指针存储在计算机内存中的哪个位置?

'this'指针究竟存储在内存中的哪个位置?它是在堆栈,堆中还是在数据段中分配的?

#include <iostream>
using namespace std;

class ClassA
{
    int a, b;

    public:
        void add()
        {
            a = 10;
            b = 20;
            cout << a << b << endl;
        }
};

int main()
{
    ClassA obj;
    obj.add();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,我调用成员函数add(),接收器对象隐式传递为'this'指针.凡被this存储在内存中?

c++ this-pointer

63
推荐指数
5
解决办法
9813
查看次数

标签 统计

c++ ×1

this-pointer ×1