fork download
  1. struct X
  2. {
  3. int& r;
  4. };
  5.  
  6. int main()
  7. {
  8. int i = 1, k = 2;
  9. X a { i };
  10. X b { k };
  11. a = b; // means a.r = b.r, which in turn means i = k
  12. std::cout << i << ' ' << k << '\n';
  13. }
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function 'X& X::operator=(const X&)':
prog.cpp:2:1: error: non-static reference member 'int& X::r', can't use default assignment operator
prog.cpp: In function 'int main()':
prog.cpp:11:9: note: synthesized method 'X& X::operator=(const X&)' first required here 
prog.cpp:12:5: error: 'cout' is not a member of 'std'
stdout
Standard output is empty