【发布时间】:2013-12-07 23:25:58
【问题描述】:
当我从下面的代码中调用 build 函数时,我收到以下编译错误:
error C3867: 'SuffixArray::cmp': function call missing argument list; use '&SuffixArray::cmp' to create a pointer to member
error C2780: 'void std::sort(_RanIt,_RanIt)' : expects 2 arguments - 3 provided
这是我的代码:
class A{
private:
std::string text;
std::vector<int> array;
bool cmp(int a, int b) {
return std::lexicographical_compare(text.begin() + a, text.end(),
text.begin() + b, text.end());
}
void build(const std::string &str, std::vector<int> &vec) {
// Some vector values actions.
std::sort(vec.begin(), vec.end(), cmp);
}
};
这里有什么问题?我正在使用 Visual C++ 编译器。
【问题讨论】:
标签: c++ sorting vector stl comparator