Is the following code safe?
class B {
public:
int& b;
B (int& _b) :
b(_b) {}
};
B* foo() {
int a;
return new B(a);
}
Will the reference in the object returned by foo point to nothing (since int a is going out of scope) or does the compile figure this out?