fork(2) download
  1. #include <stdio.h>
  2. #include <stddef.h>
  3.  
  4. struct cls
  5. {
  6. public:
  7. cls(char c, double d, int i) : c(c), d(d), i(i) {}
  8. private:
  9. char c;
  10. double d;
  11. int i;
  12. };
  13.  
  14. struct copy
  15. {
  16. public:
  17. copy(char c, double d, int i);
  18. public:
  19. char c;
  20. double d;
  21. int i;
  22. };
  23.  
  24. int main(void)
  25. {
  26. cls x('1', 2.5, 3);
  27. printf
  28. (
  29. "%c %f %d\n",
  30. *(char*)((void*)&x + offsetof(copy, c)),
  31. *(double*)((void*)&x + offsetof(copy, d)),
  32. *(int*)((void*)&x + offsetof(copy, i))
  33. );
  34. return 0;
  35. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1 2.500000 3