Re: [ROOT] TCollection(TCollection&) and its derived classes

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Mon Nov 12 2001 - 11:23:28 MET


Hi Thomas,

  the copy ctor and assignment operators for all collections (except copy ctor
for TObjArray) have been made private to prevent accidenttal anbd erroreous
use of these operators. It would be very easy to waste huge amount of resources
by allowing collections to be passed by value or it could cause all kind of
multiple deletion or memory leak problems. To quickly and explicitely copy
a collection use TCollection::AddAll() for example.

Cheers, Fons.



Thomas Bretz wrote:
> 
> Hello,
> 
> is there a reason, that all inherited members from TCollection (except
> TOrdCollection) does neither have a copy constructor, nor a =operator?
> 
> This makes the following unpossible:
> 
> TList CreateListOfSomething()
> {
>    TList list;
>    list.Add(new ...);
>    list.Add(new ...);
>    return list;
> }
> 
> TList listofsomething = CreateListOfSomething();
> listofsomething->SetOwner();
> 
> Regards,
> Thomas.

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



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