据说是微软面试题?

[复制链接]
2061|0
 楼主| wrainp 发表于 2008-4-16 21:09 | 显示全部楼层 |阅读模式
#include <iostream.h>

#pragma pack(8)
struct example1
{
short a;
long b;
};
struct example2
{
char c;
example1 struct1;
short e;
};
#pragma pack()
int main(int argc, char* argv[])
{
example2 struct2;
cout << sizeof(example1) << endl;
cout << sizeof(example2) << endl;
cout << (unsigned int)(&struct2.struct1) - (unsigned int)(&struct2) << endl;
return 0;
}
问程序的输出结果是什么?

望哪位大侠给讲解一下...
您需要登录后才可以回帖 登录 | 注册

本版积分规则

31

主题

79

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部