Hi Ingo,
In the example the length of the array fN can vary between objects.
the [fN] in the comment field of the array declaration is used by rootcint
to generate the correct code for the class Streamer function. This is a new
feature
introduced in 2.24
One particular case is when fN is a constant. In this case, you better declare
Float_t fNArray[fN];
This will be faster, no need to allocate dynamically the array for each object
separately from the object.
Rene Brun
Ingo Strauch wrote:
>
> Hi rooters!
>
> To me section 4.5 (Streamers and Arrays) of the persistency document is not
> fully clear. Does the length of the array
>
> class myclass {
> private:
> Int_t fN;
> Float_t *fNArray; //[fN]
>
> public:
> myclass (Int_t size = kDefaultSize);
>
> ClassDef(myclass,1)
> };
>
> have to be a fixed value (so I would declare it as a static [or even global]
> constant) or can each instance of the class have a different length?
>
> I mean, am I supposed to do code like that
>
> myclass::myclass(Int_t size = kDefaultSize)
> : fN(size)
> {
> fNArray = new Float_t[fN];
> }
>
> And if yes but I still wanted a fixed size for all objects, I would do the
> following declaration?
>
> static const Int_t fN;
>
> Ciao,
> Ingo
>
> ----------------------------------------------------------------------------
> Ingo Strauch Budapester Str. 30, 20359 Hamburg, Tel.: +49 40 7421 4722
> ----------------------------------------------------------------------------
> DESY, Group H1/AAC1, Room 1c354 | I.Phys.Inst. RWTH Aachen, Room 28B210
> Notkestr. 85, 22607 Hamburg | Sommerfeldstr. 14, 52056 Aachen
> Tel: +49 40 8998-2312 / Fax: -4385 | Tel: +49 241 80-7183 / Fax: 8888-661
> strauch@mail.desy.de | strauch@toots.physik.rwth-aachen.de
> ----------------------------------------------------------------------------
> www-h1.desy.de/~strauch/ or www-users.rwth-aachen.de/Ingo.Strauch/
> ----------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET