[ROOT] array of pointers ...

From: Andreas WILDAUER (andreas.wildauer@cern.ch)
Date: Thu Jul 17 2003 - 13:10:36 MEST


Hi everybody,

I have quite a strange problem:

in class CONFIG I have:

config.h: ***************
private:
Float_t m_delta[4][4];

public:
Float_t * delta(int dset);

config.C: ****************

m_delta[0][0] = 0.07;
m_delta[0][1] = 0.06;
m_delta[0][2] = 0.05;
m_delta[0][3] = 0.05;
a.s.o.

Float_t * config::delta(Int_t dset) { return m_delta[dset];}

where m_delta[0] for example is a pointer on the four Float_t's 
m_delta[0][0-3]
*******************************************************
in the CALCULATE class I have:

calculate.h: *******************
Float_t * m_delta;

and in calculate.C: *************
config configobj;
m_delta = configobj.delta(0);

So far m_delta should be a pointer on 4 Float_t's, namely: m_delta[0][0-3] 
which were defined in conifg.C.
********************************************************
now I also have a printvalues member function in class CALCULATE.
the code in MAIN program main.C is the following:

calculateobj.printvalues();
cout << "GetEntries" << endl;
fChain->GetEntry(jentry);
calculateobj.printvalues();

where fChain is a private data member of the MAIN class (which also has all 
the ntuple variables as usual (from setMakeClass)).
if i load main.C (not compiling) the output is:

m_delta[0] = 0.07
m_delta[1] = 0.06
m_delta[2] = 0.05
m_delta[3] = 0.05    // CORRECT
GetEntries
m_delta[0] = 9.3887e-44
m_delta[1] = 2.71071e-33
m_delta[2] = nan
m_delta[3] = 2.7111e-33  // ?????????????????????????

????????????????????????
how  can fChain->GetEntry(jentry); change the memory where the pointers 
m_delta[0-3] point to (which are private data members of another class, 
namely CALCULATE)  

or is it wrong to assume that array[0] is a pointer when the array is defined 
as array[4][4] (like array1 is a pointer on array1[27], what I also use and 
it works ...)

Please help
Thanks in advance
Andi Wildauer



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET