Hi,
Tayash uses const because the array index should be const. But he doesn’t want it to be const because he wants to change it. You should probably use a std::vector instead.
Axel.
I really don’t understand!
Sorry for my ignorance, but the assertion that an array wants a const
index is a request of c++ or root package?
I tell you this because sometimes I think that I use root in a naive mode
so if I could understand it in a better way I will be happy.
(and also a better programmer)
[quote=“paolomarco”]but the assertion that an array wants a const
index is a request of c++ or root package?[/quote]
The C++ standard (at 8.3.4) requires the array size to be an integral constant expression and ROOT (CINT, actually) follows that rule.
Thanks for your replies. Indeed using a vector solved that problem, but now I am facing another one. I now want to use the values I store in value as the x-values of points in a TGraphError - but TGraphError wants an array, which in turn cannot be defined with a variable size by C++ standard rules, so I’m stuck in a vicious circle
What would you recommend?
I hope I get your question right:
when you have a vector:
vector v;
and you have a function which wants a pointer to the array, you can use a reference to the first element of the vector: &v[0] as a pointer to your vector.