Hi everyone!
I canīt seem to figure out how to do correctly a clone function to an object. I searched through the board, but found nothing.
One wrong way woule be:
But at the end of the clone function, the object is destroyied, deallocating any other object inside of it.Code:const X& clone(){ return X(/*attributes*/); }
Other way:
But then, the object isnīt deallocated...Code:const X& clone(){ X* temp = new X(/*attributes*/); return *temp; }
How can I do it?
Thanks any help!



LinkBack URL
About LinkBacks


