R
raj s
How to use smart pointers with a function which takes raw pointer
raj said:How to use smart pointers with a function which takes raw pointer
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:[email protected]
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
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.