首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

sizeof()有关问题

2012-07-30 
sizeof()问题新手求助#includeiostreamusing namespace stdunion a{int a_int1double a_doubleint a_

sizeof()问题
新手求助

#include<iostream>
using namespace std;

union a 
{
int a_int1;
double a_double; 
int a_int2;
};

typedef struct
{
a a1;
char y;
} b;

class c
{
double c_double;
b b1;
a a2;
};

void main()
{
cout<<sizeof(c)<<endl;
}


结果为什么是32?

[解决办法]


字节对齐问题

你强制使用一字节对齐就好了。
[解决办法]
8+16+8

热点排行
Bad Request.