在进行编写sort函数的比较函数时,
bool compare(string str1,string str2){
string comp1=str1+str2;
string comp2=str2+str1;
return comp1 < comp2;
}
只是简单的外部声明,也没有类的引用,在VS上运行时正确,但是在其它平台上出现报错:
reference to non-static member function must be called sort(temp.begin(),temp.end(),compare);
意思是sort的调用必须是静态成员,之后声明为static后就正确了。
但是官方文档的例子没有这样的说明,