Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Empty
- {};
- class Derived1 : public Empty
- {};
- class Derived2 : virtual public Empty
- {};
- class Derived3 : public Empty
- {
- char c;
- };
- class Derived4 : virtual public Empty
- {
- char c;
- };
- class Dummy
- {
- char c;
- };
- int main()
- {
- //print the size of each class and subclasses
- cout << "sizeof(Empty) " << sizeof(Empty) << endl;
- cout << "sizeof(Derived1) " << sizeof(Derived1) << endl;
- cout << "sizeof(Derived2) " << sizeof(Derived2) << endl;
- cout << "sizeof(Derived3) " << sizeof(Derived3) << endl;
- cout << "sizeof(Derived4) " << sizeof(Derived4) << endl;
- cout << "sizeof(Dummy) " << sizeof(Dummy) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement