我在使用排序功能时遇到了一些问题......这是我的代码:
class Parola {
public:
string s;
int repetition;
bool operator()(const Parola *x, const Parola *y) {
return x->repetition > y->repetition;
}
};
int main(int argc, char** argv) {
...
vector<Parola> p;
...
some insertions here
...
sort(p.begin(), p.end(), Parola());
...
return 0;
}
为什么我不能在没有错误的情况下编译它?非常感谢!
PS:我只会向您展示超过五十个错误的前三行:
/usr/include/c++/4.2.1/bits/stl_algo.h: In function 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp = Parola, _Compare = Parola]':
/usr/include/c++/4.2.1/bits/stl_algo.h:2795: instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Parola*, std::vector<Parola, std::allocator<Parola> > >, _Size = long int, _Compare = Parola]'
/usr/include/c++/4.2.1/bits/stl_algo.h:2866: instantiated from 'void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Parola*, std::vector<Parola, std::allocator<Parola> > >, _Compare = Parola]'