fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. union {
  6. /*struct {
  7.   double xyz[3];
  8.   };*/
  9. double x, y, z;
  10. double a, b, c;
  11. };
  12. };
  13.  
  14. int main()
  15. {
  16. A a;
  17. a.a = 1.5;
  18. a.b = 2.12;
  19. a.c = 3.14;
  20.  
  21. cout << a.a << endl << a.b << endl << a.c << endl;
  22. cout << a.x << endl << a.y << endl << a.z << endl;
  23. cout << sizeof(a) << endl;
  24. }
  25.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
3.14
3.14
3.14
3.14
3.14
3.14
8