Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8033246
  • 博文数量: 594
  • 博客积分: 13065
  • 博客等级: 上将
  • 技术积分: 10324
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 16:44
个人简介

推荐: blog.csdn.net/aquester https://github.com/eyjian https://www.cnblogs.com/aquester http://blog.chinaunix.net/uid/20682147.html

文章分类

全部博文(594)

分类: C/C++

2017-06-15 09:52:54

C++11将addressof作为标准库的一部分,用于取变量和函数等内存地址。


代码示例:
#include
#include


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
阅读(2710) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~