Can anybody explain why this code does not generate a compiler error?
class Foo
{
public:
int _x;
};
Foo getFoo()
{
Foo myfoo;
myfoo._x = 10;
return myfoo;
}
int _tmain()
{
// shouldn't this line of code be a compiler error?
Foo& badfoo = getFoo();
return 0;
}