小编Wyj*_*jun的帖子

变量地址

看看这段代码:

class Test
{
    //
};

Test TestAddress()
{
    Test test;
    cout << "Object Address in function: " << (int)&test << endl;
    return test;
}

int IntAddress()
{
    int test;
    cout << "Integer Address in function: " <<(int)&test << endl;
    return test;
}

int main() {

    int x = IntAddress();
    cout << "Integer Address in Main: " <<(int)&x << endl;

    Test object = TestAddress();
    cout << "Object Address in Main: " <<(int)&object << endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是:

功能中的
整数地址:1076679252 …

c++ memory-address

2
推荐指数
1
解决办法
105
查看次数

标签 统计

c++ ×1

memory-address ×1