I came to know that Temporaries
connot be bound to non-const references.
class X
{
int i;
};
X fun()
{
return X();
}
void func(X &x)
{
}
int main()
{
func(fun());
return 0;
}
Isn't call to fun
producing a temporary? Why can temporary be linked to non-const reference
here. I am unable to comprehend as to why is this compiling fine.
EDIT: I am using VS2010. I don't understand how should this matter.