Data member TClonesArray in TObject inheritance

From: William J. Deninger (deninger@uiuc.edu)
Date: Wed Dec 31 1997 - 22:40:13 MET


Hello,

I've discovered that I'm unable to compile a class with a TClonesArray data
member using MCVC v5.0 compiler without an error.  Is it not syntactically
correct to have a data member use a specialized constructor within the class
declaration?

//  code..
#include "TObject.h"
#include "MPXPAIR.h" // class MPXPAIR inherits TObject
#include "TClonesArray.h"
class Simple : public TObject
{
public:
 Simple();
 virtual ~Simple();
 TClonesArray tracks("MPXPAIR", 10);
 ClassDef(Simple,1)
};

// compile message
Compiling...
Simple.cpp
D:\Root-Trace\Simple.h(18) : error C2059: syntax error : 'string'
Error executing cl.exe.
Simple.obj - 1 error(s), 0 warning(s)

Of course, if I have the a variable of type TClonesArray instantiated from
within a member function, things compile perfectly but I loose the "public"
accessibility of the variable.  To get around the error I can make the
declared data member a pointer of type TClonesArray and having the memory
allocated and constructor called from with the Simple class constructor.
But this seems to have repercussions on my ability to use Simple in a TTree
with splitlevel = 1.  My whole reason for using TClonesArray was to get away
from pointers.

How should I be approaching this?  And much thanks for all your help.


William Deninger
deninger@uiuc.edu



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:23 MET