Re: boost/scoped_ptr or new/delete
On Jul 11, 12:50 am, none <""john\"@(none)"> wrote:
At work we have someone who believes that using new&delete is a hideous
sin. He believes it should never be used. Instead scoped_ptr is the
enlightened way.
Does anyone have a view?
There's no silver bullet. Scoped_ptr only works when object
lifetime corresponds to some scope. Shared_ptr is also useful
for some short lived objects that you pass around, but that you
cannot easily copy (typically because they have to be
polymorphic). I use auto_ptr a lot to transfer ownership
between threads, but that's a special case. In most
applications, however, most pointers will be just your classical
T*, since most of the objects you will be allocating dynamically
will be entity objects, with application determined lifetimes.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34