Explore BrainMass
Share

Iterators

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

See the attached file.
Implement the function maxLoc(), which returns an iterator pointing at the largest element in a list.

//return an iterator pointing to the largest element
//in the list.

template <typename T>
list<T>::iterator maxLoc(list<T>& aList);

Write a program that tests maxLoc(), using the following declarations:

string strArr[] = ("insert", "erase", "template", "list");
int strSize = sizeof(strArr)/sizeof(string);
list<string> strList(strArr, strArr+StrSize)

The program should repeatedly call maxLoc(), output the largest value, and then delete the value, until the list is empty.

I am attaching a .cpp file of the program. It is mostly complete but when I compile I don't seem to get the right result.

© BrainMass Inc. brainmass.com September 21, 2018, 1:46 pm ad1c9bdddf - https://brainmass.com/computer-science/algorithms/implement-function-returning-interator-176160

Attachments

Solution Summary

The solution implements the function maxLoc(), which returns an interator pointing at the largest element in a list.

$2.19