Re: TClonesArray

From: Roman Lietava <rl_at_hep.ph.bham.ac.uk>
Date: Thu, 2 Jul 2009 23:07:37 +0100


Thank you, Fons.
I am confused.
What are the methods I found at:
http://root.cern.ch/root/html/src/TClonesArray.cxx.html#gv6UBD which are called
TClonesArray::TClonesArray(const TClonesArray& tc): TObjArray(tc) {

   // Copy ctor.
...
}
TClonesArray& TClonesArray::operator=(const TClonesArray& tc) {

   // Assignment operator.
...
}
?
Why I cannot use them ?
Roman.

On Thu, 2 Jul 2009, Fons Rademakers wrote:

> Hi Roman,
>
> as clonesarrays are generally large objects we don't have assignment
> and copy ctors for them. If you really want to copy or assign objects
> containing TClonesArrays, you will have to loop over these arrays yourself
> and copy the information. If you use a pointer to a clones array you can
> use the TObject::Clone() method:
>
> TClonesArray *b = (TClonesArray*)a->Clone()
>
> Cheers, Fons.
>
>
>
> > Can you show me or point me to example how
> > to use TClonesArray in copy constructor and
> > in assignemnt operator, please?
> > Thanks,
> > Roman.
> >
> > E.g.:
> >
> > class item{
> > };
> >
> >
> > class myclass{
> > TClonesArray array; // array of item objects
> > } ;
> >
> > myclass::myclass(const myclass &class ){
> > }
> >
> > myclass& myclass::operator=(const myclass &class)
> > {
> > if(this!=&class){
> > }
> > }
>
>

-- 
Received on Fri Jul 03 2009 - 00:07:42 CEST

This archive was generated by hypermail 2.2.0 : Fri Jul 03 2009 - 11:50:02 CEST