fork download
  1. #include <iostream>
  2.  
  3. #pragma pack(push, 1)
  4. struct A
  5. {
  6. int a;
  7. char b;
  8. };
  9. #pragma pack(pop)
  10.  
  11. struct B : public A
  12. {
  13. int c;
  14. };
  15.  
  16. int main()
  17. {
  18. std::cout << "Size of A: " << sizeof(A) << std::endl;
  19. std::cout << "Size of B: " << sizeof(B) << std::endl;
  20. return 0;
  21. }
Success #stdin #stdout 0.02s 2680KB
stdin
Standard input is empty
stdout
Size of A:  5
Size of B:  12