fork download
  1. struct X
  2. {
  3. char* x;
  4. X()
  5. {
  6. x = new char('a');
  7. }
  8. ~X()
  9. {
  10. *x = 'b';
  11. delete x;
  12. }
  13. };
  14.  
  15. void foo(const X& x)
  16. {
  17. }
  18. void goo(X& x)
  19. {
  20. }
  21.  
  22. int main()
  23. {
  24. foo(X());
  25. goo(X());
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:25: error: invalid initialization of non-const reference of type ‘X&’ from a temporary of type ‘X’
prog.cpp:18: error: in passing argument 1 of ‘void goo(X&)’
stdout
Standard output is empty