5 Aug
2010
5 Aug
'10
4:13 p.m.
archie14 skrev:
Roman Perepelitsa
writes: class Compare { public: Compare (int i) : _i(i){} //this does not compile, but what's the proper way to define // function object for the sort method in ptr_vector? bool operator<(const A& v1, const A& v2) { return (v1.i > v2.i) &&(_i != 1); } ... }; Try making your operator const: bool operator<(const A& v1, const A& v2) const
Roman Perepelitsa.
No, it did not work. Complains that
binary 'operator <' has too many parameters
Indeed, when defining the comparison operator as a member you need to supply only one argument. HTH -Thorsten