Here are 2 functions I wrote where I think the problem is:
template <typename T>
typename list<T>::iterator maxIter(typename list<T>::iterator first,typename list<T>::iterator last)
{
list<T>::iterator max = first;
while(first != last)
{
if (*first > *max)
max = first;
first++;
}
return max;
}
template <typename T>
void selectionSort(list<T>& aList)
{
list<T>::iterator passIter = aList.begin(), maxVal;
for(int i = 0; i<aList.size(); i++)
{
maxVal = maxIter<T>(passIter, aList.end());
aList.push_front(*maxVal);
aList.erase(maxVal);
}
}
template <typename T>
typename list<T>::iterator maxIter(typename list<T>::iterator first,typename list<T>::iterator last)
{
list<T>::iterator max = first;
while(first != last)
{
if (*first > *max)
max = first;
first++;
}
return max;
}
template <typename T>
void selectionSort(list<T>& aList)
{
list<T>::iterator passIter = aList.begin(), maxVal;
for(int i = 0; i<aList.size(); i++)
{
maxVal = maxIter<T>(passIter, aList.end());
aList.push_front(*maxVal);
aList.erase(maxVal);
}
}