Hello,
I have a function that allocates two variables on the heap and returns them to the caller. Something like this:
void Create1(Obj** obj1, Obj** obj2)
{
*obj1 = new Obj;
*obj2 = new Obj;
}
Usually, in similar cases, when I have a function with one variable I use the "source" trick with auto_ptr
:
auto_ptr<Obj> Create2()
{
return new Obj;
}
I would like to rewrite Create1
using auto_ptr
but not sure how to do it. As far as I understand I cannot return auto_ptr by reference, am I right? So is it possible at all?