Why does multiple inheritance increase the size of the object despite the bases being empty?
- 阅读更多 关于 Why does multiple inheritance increase the size of the object despite the bases being empty?
问题 Given this code: #include <iostream> struct A { }; struct B { }; struct C { }; struct E : A { int field; }; struct F : A, B { int field; }; struct G : A, B, C { int field; }; int main() { std::cout << _MSC_VER << std::endl; std::cout << sizeof(E) << std::endl; std::cout << sizeof(F) << std::endl; std::cout << sizeof(G) << std::endl; int o; std::cin >> o; return 0; } I am given the following output: 1900 4 8 8 Why would F and G have sizes of 8 even though their bases are empty? And why would