I came across such a code.
MyClass MyClass::get_information (const some_datastructure *record) { auto_ptr<MyClass > variable (new MyClass ()); variable ->set_article_id(record->article_id); return *variable.get(); }
I understand that this returns (a copy?) An object of type MyClass. Initially, I thought that it returns an auto_ptr object, which does not make sense to me (?) Since I thought that the auto_ptr object will be destroyed when it goes beyond the scope.
Anyway, is this the code above? Does the object *variable.get() exist when / after the function returns?
source share