On Jul 27, 10:02 pm, "AnonMail2...@gmail.com" <AnonMail2...@gmail.com>
wrote:
How to use smart pointers with a function which takes raw pointer
Just pass the raw pointer to the function (e.g. use get () or whatever
memeber function your particular smart pointer has to retrieve the raw
pointer it holds)
A well designed stand alone function should not delete the
pointer (it didn't allocated the object did it?) and since the
object exists before the function was called (and will after
the function is called) there is no need to manage it's
memory.
That depends on what the function is supposed to do. If the
function's role involves deleting the object, it should delete
it. Otherwise, you'll end up with a lot of memory leaks.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34