I think I learn from TC++PL that "A non-const reference should be initialized by a left-value".
And the following is my question
int f1(int &x)
{
return 1;
}
int f2()
{
return 1;
}
int f3(string &s)
{
return 1;
}
string f4()
{
return "1";
}
int main()
{
cout<<f1(f2())<<endl; // Error.
cout<<f3(f4())<<endl; // OK.
}
So I cann't understand that why f3(f4()) is correct while the return value of f4() is obvious not a left-value.