#include <iostream> using namespace std; void foo(int& refArg) { } int bar() { return 5; } int main() { foo(bar()); return 0; }
Standard input is empty
prog.cpp: In function ‘int main()’:
prog.cpp:16:9: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int’
foo(bar());
~~~^~
prog.cpp:5:6: note: initializing argument 1 of ‘void foo(int&)’
void foo(int& refArg)
^~~
Standard output is empty