Re: Copy constructor of TObjArray (LinkDef added)

From: Vassili Maroussov <Vassili.Maroussov_at_cern.ch>
Date: Wed, 21 Apr 2010 12:11:36 +0200

Dear Rene,

for some reason it doesn't work for standalone executable, please find example in the attachment. The "testclone" output shows that objects in the collection aren't copied both for the Clone() (T2) and the copy constructor (T3) :

[vmarouss_at_Ezhik-HDX18 TestClones]$ ./testclone Entry #0

T1: (MyClass): X=0.5    Y=-0.5
T2: (MyClass): X=0    Y=0
T3: (MyClass): X=0    Y=0

Entry #1
T1: (MyClass): X=1.5    Y=-1.5
T2: (MyClass): X=0    Y=0
T3: (MyClass): X=0    Y=0

Entry #2
T1: (MyClass): X=2.5    Y=-2.5
T2: (MyClass): X=0    Y=0
T3: (MyClass): X=0    Y=0

OS: Fedora12, ROOT version 5.25.03, gcc version 4.4.3 20100127 (Red Hat 4.4.3-4) (GCC) Target: x86_64-redhat-linux

Regards,

Vassili

On 04/20/2010 02:53 PM, Rene Brun wrote:
> Hi Vassili,
>
> If you want to make a deep copy of all the objects in the collection
> for a TObjArray *a (or TClonesArray), do
> TObjArray *b = (TObjArray*)a->Clone();
>
> Rene Brun
>
> Vassili Maroussov wrote:
>> Dear ROOTers,
>>
>> It seems the copy constructor of TObjArray and TClonesArray copies
>> only the pointers' array but doesn't create copies of objects in
>> collection, correct?
>>
>> Regards,
>>
>> Vassili
>>
>

Received on Wed Apr 21 2010 - 12:11:41 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 21 2010 - 17:50:01 CEST