I am not quite clear if auto_ptr will help me in this case:
class A
{
A(const B& member)
: _member(B)
{};
...
const B& _member;
};
A generateA() {
auto_ptr<B> smart(new B());
A myA(*smart);
return myA;
}
Will the myA._member
reference be valid when smart
leaves its enclosing scope? If auto_ptr isn't the answer here, what is?
EDIT: I see where I confused everyone; I have to return myA outside the scope, which is why I care about _member being valid after smart exits the scope.