Why does the compiler allow a function to return a value that is stored as a reference
- by kern
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()
{
// should this line of code not be a compiler error?
Foo& badfoo = getFoo();
return 0;
}