class A { }; class B { int a[]; }; int main() { cout << sizeof(A) <<endl; //outputs 1 cout << sizeof(B) <<endl; //outputs 0 return 0; }
我很熟悉,空类的大小是1,但为什么B类的大小是零?
和:
As a quirk of the original implementation of zero-length arrays,sizeof evaluates to zero.