doesn’t mean that the method return a vector. The vector is an argument.
I think it means that you can set the values of vector out with the method meth. But I’m interested in the Getmeth mehod, to get the values of the vector.
So to get a vector I’am looking for a method that returns a vector. Or in this cased a method that returns an array.
Hi,
why do you think you needa method returning an array? I don’t want to appear arrogant here, but if you wonder about questions like these you really should use a vector&, fill it in the method, and use it from outside: [code]void MyFunc(std::vector<Double_t>& out) {
out.clear(); // reset whatever was in out
out.resize(10, 0.); // make sure out has exactly 10 elements
for(Int_t = 0; i < 10; ++i)
out[i] = i*0.1; // and set their values
}
Double_t AverageOfMyFunc() {
// cald the average of MyFunc’s vector
std::vector<Double_t> values;
MyFunc(values); // set values
Double_t ret = 0.;
for (Int_t i = 0; i < values.size(); ++i)
ret += values[i];
return ret / values.size();
}[/code]It’s efficient and safe. If you really need to return an array (again - I doubt you need that) then use the Double* MyFunc() syntax I already mentioned in my previous posting.
I could use a dinamic array or a vector, but I think is more easier with arrays than with vectors. I only need an array with a dimension that can be fixed with a variable, instead of use a value, as with simple arrays in C. I don’t need to add elements to the array without the dimension fixed, like a vector, and also, is more complicated than arrays I think, is more advanced.