获取成员变量的地址和偏移地址
2016-03-10 17:15
330 查看
#include<iostream> using namespace std; struct Point3D{ int a; int b; int c; }; int main(){ Point3D *p = NULL; int offset = (int)(&(p)->c); int i = (int)(&(p->c)); cout << &(p->c) << endl; cout << i << endl; cout << offset << endl; cout << "............" << endl; int j = (int)(&(*p).c); cout << j << endl; Point3D p3d; int k = (int)(&p3d.c); cout << k << endl; return 0; }
$ ./a 0x8 8 8 ............ 8 2686712
相关文章推荐
- 诚品快拍隆重挂牌 :突显“扫码”领域领军品牌
- 重磅消息!AppCan扩容机制上线,扩大空间随心所欲!
- 升级到 ExtJS 5的错误解决方案
- Spring声明式事务管理的两种方式(XML和Annotation)
- 开源框架之xUtils
- [windows]查找端口占用,并结束
- Suricata规则编写——常用关键字
- nrf51822 --- 设置发送功率
- Hibernate框架简述
- 【UVA12093】Protecting Zonk (树形DP)
- [Leetcode]@python 108. Convert Sorted Array to Binary Search Tree
- HDU 1728 逃离迷宫
- objective-c的des、3des加密的一些方法
- 将博客搬至CSDN
- ios 判断某个时间是周几的方法
- ubuntu下安装vmware11
- ios 判断当前时间是否在某个时间段的方法
- iOS 程序在UITextView中显示NSLog日志的方法,
- Java泛型详解
- HDU 1.1.1 A+B for Input-Output Practice (I)