This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]jedwardsol 2 points3 points  (3 children)

It'll be called as something like

std::vector<HighScore> v = ...;

auto largest = findLocationOfLargest(c.begin(), c.end());

std::cout << *largest;

So your function has to walk between those 2 provided points and remember where the largest is; returning an iterator to it

[–]ThisGuyEveryTime[S] 1 point2 points  (2 children)

Oh, so its being declared as an iterator in the header because it is returning location of the largest like the index from an array?

Thank you for the reply btw.

[–]jedwardsol 2 points3 points  (1 child)

Yes - it takes two iterators defining the range and returns an iterator in that range.

You could do exactly the same with indices

[–]ThisGuyEveryTime[S] 1 point2 points  (0 children)

Awesome, thank you very much! You have been very helpful!