I wrote myself a compare function for sort(). It worked well when I put it this way.
bool comp(string a, string b)
{
...;
}
int main()
{
sort(...,...,comp);
}
然而,当我把这一切放在一个班子里时,我要说:
class Test {
public:
bool comp(string a,string b)
{
...;
}
vector <string> CustomSort(vector <string> str) {
sort(...,...,comp);
}
};
There is a compile error "No matching function for call to sort ...... .
为什么会发生这种情况?