Hi Victor,
If the list is a TClonesArray or any other type for which you called
SetOwner (Thomas's case), whend doing delete list, this will also
delete the objects inside the list.
Rene Brun
On Thu, 1 Nov 2001, Victor Perevoztchikov wrote:
> 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