If I have a vector v={1,2,4,6,8} and I find my maximum element of this vector using this:

"

vector<int>::iterator iter_max = max_element(v.begin(), v.end());

cout<<"Largest element is "<< *iter_max;

"

which works fine. But I need to know the position of this max element. Is it second, third or fourth in my vector structure? What is the position of my max element in my vector? Can anyone help please?

JasonHippy 724

JasonHippy 724

Nick Evan 4,005

JasonHippy
commented:
Very handy..Not seen distance used before! +3

JasonHippy 724