fork download
  1. #include <iostream>
  2.  
  3. #pragma pack(push,1)
  4. class Foo1
  5. {
  6. short int a;
  7. char b;
  8. };
  9.  
  10. class Foo2
  11. {
  12. char a;
  13. char b;
  14. char c;
  15. };
  16. #pragma pack(pop)
  17.  
  18. int main()
  19. {
  20. std::cout
  21. << sizeof(Foo1)
  22. << " "
  23. << sizeof(Foo2)
  24. << std::endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
3 3