#include <iostream> using namespace std; class Empty1 { }; class Empty2 { public: Empty2(){}; ~Empty2(){}; }; class Empty3 { public: Empty3(){}; virtual ~Empty3(){}; }; int main() { cout<<sizeof(Empty1)<<endl; //1 cout<<sizeof(Empty2)<<endl; //1 cout<<sizeof(Empty3)<<endl; //4 return 0; }
参考:《剑指offer》 p22