编译器会强制没有数据成员的对象长度非零

C++语言: Codee#25742
01 #include <iostream>
02 #include <cstdio>
03 using namespace std;
04
05 class NotEmpty
06 {
07
08 };
09
10 int main()
11 {
12     cout<<sizeof(NotEmpty)<<endl;
13     return 0;
14 }
15
16 /*
17 1
18
19 Process returned 0 (0x0)   execution time : 0.027 s
20 Press any key to continue.
21
22
23 */
原文地址:https://www.cnblogs.com/invisible/p/2384661.html