max_element function


Dear all,
I would like to know the type that is returned by max_element function: is it the max value in a vector or a pointer to the maximum value? Actually, I am trying to write a code that returns the position of the max in one vector and then accesses to the same position in an other vector to increment the value which is stored there, but when I compile, I have this error message: cannot convert ‘float’ to ‘int*’ in assignment

here the code snippet which is concerned:

int interm = 0 ;
vector<int> UE_scheduled;
vector<float> metric;
vector<int> counter;
UE_scheduled.at(i) = max_element(metric.at(0), metric.at(nbre_UE));
interm = UE_scheduled.at(i);
counter.at(interm) = counter.at(interm) + 1;

Thanks in advance for any suggestions.
There is such notion as documentation. Before something to use the documentation should be read.

So please read the description of standard algorithm std::max_element before to use it.
max_element takes two iterators as argument and returns an iterator to the largest element.

If you don't know what an iterator is you should probably learn about it now.
Topic archived. No new replies allowed.