fork download
  1. #include <iostream>
  2.  
  3. struct ManyIntegers {
  4.  
  5. int a,b,c,d;
  6. };
  7.  
  8. int main () {
  9.  
  10. union {
  11. int ManyIntegers::* p;
  12. unsigned long l;
  13. } x;
  14.  
  15.  
  16. x.p = &ManyIntegers::a;
  17. std::cout << "p = &ManyIntegers::a = " << (x.l) << std::endl;
  18.  
  19. x.p = &ManyIntegers::b;
  20. std::cout << "p = &ManyIntegers::b = " << (x.l) << std::endl;
  21.  
  22. x.p = &ManyIntegers::c;
  23. std::cout << "p = &ManyIntegers::c = " << (x.l) << std::endl;
  24.  
  25. x.p = &ManyIntegers::d;
  26. std::cout << "p = &ManyIntegers::d = " << (x.l) << std::endl;
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
p = &ManyIntegers::a = 0
p = &ManyIntegers::b = 4
p = &ManyIntegers::c = 8
p = &ManyIntegers::d = 12