Here is the problem code I'm trying to compile:
bool TeamMatcher::simpleComparator(Student first, Student second){
return (first.numberOfHrsAvailable < second.numberOfHrsAvailable);
}
void TeamMatcher::sortRosters(){
sort(rosterExcellent.begin(), rosterExcellent.end(), simpleComparator);
sort(rosterGood.begin(), rosterGood.end(), simpleComparator);
sort(rosterOK.begin(), rosterOK.end(), simpleComparator);
sort(rosterPoor.begin(), rosterPoor.end(), simpleComparator);
sort(rosterNoSay.begin(), rosterNoSay.end(), simpleComparator);
}
Then here is the error I get:
TeamMatcher.C: In member function ‘void TeamMatcher::sortRosters()’:
TeamMatcher.C:51: error: no matching function for call to ‘sort(__gnu_cxx::__normal_iterator<Student*, std::vector<Student, std::allocator<Student> > >, __gnu_cxx::__normal_iterator<Student*, std::vector<Student, std::allocator<Student> > >, <unresolved overloaded function type>)’
/usr/include/c++/4.2.1/bits/stl_algo.h:2852: note: candidates are: void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Student*, std::vector<Student, std::allocator<Student> > >, _Compare = bool (TeamMatcher::*)(Student, Student)]
This error is repeated for the four remaining varieties. I do not understand, I am basically copying / pasting this solution here: http://www.cplusplus.com/reference/algorithm/sort/
Any help would be greatly appreciated!
user114518
source
share