在CPP 中关于Struct 对齐的问题
struct A {
char a;
int c;
long long d;
char b;
};
struct B {
char a,f;
int c;
char b;
long long d;
};
class C {
};
int main() {
long long b = 23;
cout << sizeof(b) << endl; //8
cout << sizeof(A) << endl; //24
cout << sizeof(B) << endl; //24
cout << sizeof(C) << endl; //1
system("pause");
}
详细解释:https://blog.csdn.net/keyearth/article/details/6129882