There is one thing I never understood about references and I hope that one might help me. For all I know, a reference cannot be null. But what happens if you have a function foo() returning a reference to an stack object:
Object & foo(){
Object o;
return o;
}
Object & ref = foo();
Theoretical ref would refer to an non existing object since o runs out of scope as soon as the function returns. Whats happening here?