fork download
  1. #include <iostream>
  2.  
  3. struct s1{
  4. int x, y, z;
  5. };
  6.  
  7. struct s2{
  8. int x, y, z;
  9. };
  10.  
  11. int main(){
  12. s1 s{};
  13. ((s2&)s).z = 10;
  14. std::cout << s.z << '\n';
  15. }
Success #stdin #stdout 0s 4496KB
stdin
Standard input is empty
stdout
10