我有以下代码:
#pragma pack(push, 4) class C { public: char a; char b; short c; char d; }; C e;
我不明白为什么sizeof(e)是6.我认为sizeof(e)将是8 => 1(a)+ 1(b)+ 2(c)+ 1(d)+ 3(对齐)
sizeof(e)
c++ sizeof pragma memory-alignment memory-layout
c++ ×1
memory-alignment ×1
memory-layout ×1
pragma ×1
sizeof ×1