C++11将addressof作为标准库的一部分,用于取变量和函数等内存地址。 代码示例: #include <memory> #include <stdio.h> void f() {} int main() { int m; printf("%p\n", std::addressof(m)); // 一些环境非C++11可用std::__addressof printf("%p\n", std::addressof(f)); return 0; } 运行输出示例: 0x7ffc983b699c 0x4005f0 相关文章: