Re: [ROOT] on whether to delete root objects

From: Victor Perevoztchikov (perev@bnl.gov)
Date: Thu Nov 01 2001 - 20:04:19 MET


Hi Thomas,

> delete list;
this does not delete any objects (in heap or not)

You should do:

list->Delete();
delete list;

Victor

Thomas Bretz wrote:
> 
> Hi Rene,
> 
> does this mean, that:
> 
> {
> TList *list = new TList;
> MyClass a;
> MyClass *b = new MyClass;
> list.Add(&a);
> list.Add(b);
> list->SetOwner();
> [...]
> delete list;
> }
> 
> is correct code and does no segfault?
> 
> Regards,
> Thomas.
> 
> > With
> >  - MyClass *c = new MyClass(); c is on the heap
> >  - MyClass c;  c is in the stack
> >
> > > Something I never understood... When is a object 'on the heap'?

-- 
Victor M. Perevoztchikov   perev@bnl.gov  perev@vxcern.cern.ch       
Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000
tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:05 MET