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