#include <iostream> // Invalid example:void foo(int& x){ std::cout << x << std::endl;} int main(){ // not legal; can't bind a temporary to a non-const reference (because what if foo() changed it?) foo(7 * 6);}
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:12: error: invalid initialization of non-const reference of type ‘int&’ from a temporary of type ‘int’ prog.cpp:4: error: in passing argument 1 of ‘void foo(int&)’
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!