首页 > 编程语言 >c++ 获取对象地址和从地址获取对象

c++ 获取对象地址和从地址获取对象

时间:2022-12-06 11:22:05浏览次数:53  
标签:std 对象 long 获取 地址 c++

#include <iostream>
using namespace std;

int main()
{
    const char* a = "I am the data";
    long long addr = (long long)(std::addressof(a));
    cout << "address of a:" << addr << endl;
    const char* b = *(const char**)addr;
    cout << "b:" << b << endl;
    return 0;
}

 

标签:std,对象,long,获取,地址,c++
From: https://www.cnblogs.com/nanfei/p/16954700.html

相关文章