Problem when using the user classes in TSelector

Hello,

I have a problem to use an object of the class A in myTSelector code when that class has a member reference of type B. Both classes are inherited from TObject. Here is an example :

class A: public TNamed { public: ... B* b; ... ClassDef(A,1); }

I think I generate the class dictionary correctely (?) I have the following line in the corresponding LinkDef.h file of the A-class:

The class B can be any of the ROOT classes, e.g., TH1D.

Later, I create an object of the type A in myTSelector methods (actually, in the SlaveBegin()). I don’t have any problem when running my code in a normal root mode (so, no proof). But the proof jobs fail. I am pretty sure that this happens because of B* b data member. Is there a way to solve this problem? Am I missing some important pieces when generating a dictionary for the class A?

If I replace ‘B* b’ by ‘B b’ then it works again. But declaring of objects in headers instead of pointers is something, which I don’t want to do.

Thank you very much in advance for any help.

Cheers, Gia

[quote]If I replace ‘B* b’ by ‘B b’ then it works again. But declaring of objects in headers instead of pointers is something, which I don’t want to do. [/quote]Maybe you did not properly initialize the pointer in all the constructor of A or maybe the destructor of A is deleting the object even though it is also attached to a file and this file has already been closed.

Cheers,
Philippe.

Hi Philippe,

Thanks lot. You gave me a right hint. It seems that one needs to set all member pointers to 0 in the class constructors. I added that missing initialization to my example class:

And the problem with proof was solved.

Cheers, Gia

[quote] It seems that one needs to set all member pointers to 0 in the class constructors.[/quote]Indeed, this is always true in C++ wether or not you are using C++.

Cheers,
Philippe.