Thomas, In addition to Fons' answer to your mail, I want to add that, in ROOT in general, you can make a copy of any TObject via TObject::Clone. This is also true for collections. eg TList list; list.Add(new xxx); list.Add(new yyy); ...etc //now copy this list TList *newlist = (TList*)list.Clone(); newlist will be a straight copy of list with all its components, components of components, etc. The Clone function is based on the standard ROOT I/O serialization via Streamers. I also draw your attention to the recently implemented TRefArray class in case you want to build lists with references. Rene Brun Fons Rademakers wrote: > > 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