fork download
  1. #include<iostream>
  2.  
  3. struct B {
  4. union U {
  5. struct S {
  6. // some data
  7. } s;
  8. int i = 100;
  9. }
  10. u;
  11. };
  12.  
  13. int main () {
  14. B obj;
  15. std::cout << "obj.u.i = " << obj.u.i << "\n";
  16. }
  17.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
obj.u.i = 0