struct X { char* x; X() { x = new char('a'); } ~X() { *x = 'b'; delete x; } }; void foo(const X& x) { } void goo(X& x) { } int main() { foo(X()); goo(X()); }
Standard input is empty
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&)’
Standard output is empty