Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. [shoorik@devproxy-test-v ~]$ cat a.cpp
  2. #include <stdio.h>
  3.  
  4. struct T1 {
  5.   char a;
  6.   int b;
  7. };
  8.  
  9. class T2 {
  10. public:
  11.   char a;
  12.   int b;
  13. };
  14.  
  15. class T3 {
  16. public:
  17.   char a;
  18.   int b;
  19.   virtual void foo() {
  20.   }
  21. };
  22.  
  23. struct __attribute__ ((__packed__)) T4 {
  24.   char a;
  25.   int b;
  26. };
  27.  
  28. int main () {
  29.   return printf ("%d %d %d %d\n", sizeof(T1), sizeof(T2), sizeof(T3), sizeof(T4));
  30. }
  31. [shoorik@devproxy-test-v ~]$ g++ a.cpp
  32. [shoorik@devproxy-test-v ~]$ ./a.out
  33. 8 8 16 5
  34. [shoorik@devproxy-test-v ~]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement