Problem with variable length array of custom class in a TTre

Hi,

I have a problem accessing members of a variable length array of custom class objects with the TTree::Scan method.

I have attached a macro which reproduces the problem. There are two simple classes, the first ‘subDataClass’ contains a single parameter (int param). The second ‘mainDataClass’ contains a variable length array of subDataClass created as follows:

int nVar;
subDataClass* data;//[nVar]

I have a small function called go() which creates the class and fills dummy values into a TTree. Now, if I use the following:

TTree::Scan(“data[1].param”)

then all the values are zero, instead of the dummy value.

any help appreciated

Peter
System OS X 10.6.6, Root SVN revision 37585, gcc 4.2.1

Sorry - forgot the attachment!
example.C (1.45 KB)

Hi,

I can indeed reproduce the problem which is not easy to fix.
As a work-around, please replace your C-style array of object by a std::vector of object.

Cheers,
Philippe.

Hi - this workaround works

thanks
Peter