Hi rooters,
can anyone explain me what the difference is in between the following two line sets:
1)
const Float_t fgkAl3parameters[3] = {3., 4., 0.1};
Float_t *ccc;
for (Int_t ii=0; ii<3; ii++) ccc[ii] = fgkAl3parameters[ii];
cout << ccc[0] << " " << ccc[1] << " " << ccc[2] << endl;
2)
const Float_t fgkAl3parameters[3] = {3., 4., 0.1};
Float_t *ccc = &fgkAl3parameters;
cout << ccc[0] << " " << ccc[1] << " " << ccc[2] << endl;
?
In ROOT framework:
if I use the first line set, I have a segmentation violation;
if I use the second one, I haven't problem.
And again,
I made a macro (attached to this email):
this macro contains two methods,
one per each of the previously reported possibilities.
When I made the following:
.L proviamo.C
the compilation is ok,
but the first method execution ends with a segmentation violation
and the execution of the second one ends correctly.
When I made the following:
.L proviamo.C++
the compilation stops with the following message:
./proviamo.C:31: error: cannot convert `const Float_t (*)[3]' to `Float_t*' in initialization
If I comment the second method content,
the compilation ends correctly
and the first method execution also.
Thank you for you help
Best regards
Annalisa
This archive was generated by hypermail 2.2.0 : Fri Nov 09 2007 - 23:50:01 CET