Первые два выдают последний... взял отсюды http://answers.yahoo.com/question/index?qid=20080725034648AAQSmvq
class Ranking {
private:
int k;
struct Racer {
int id;
int points;
bool operator<(const Racer &b) {
if (this->points < b.points) return true;
return this->id < b.id;
}
};
vector<Racer> r;
public:
...
void profit(...!!!);
sort(r.begin(),r.end());
In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/algorithm:63:0,
from Vehicles.hpp:7,
from Clasification.hpp:4,
from Ranking.hpp:4,
from Ranking.cpp:1:
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h: In function ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Ranking::Racer*, std::vector<Ranking::Racer> >, _Tp = Ranking::Racer]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2253:70: instantiated from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Ranking::Racer*, std::vector<Ranking::Racer> >]’
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2284:54: instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Ranking::Racer*, std::vector<Ranking::Racer> >, _Size = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:5330:4: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Ranking::Racer*, std::vector<Ranking::Racer> >]’
Ranking.cpp:22:27: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/stl_algo.h:2215:4: error: passing ‘const Ranking::Racer’ as ‘this’ argument of ‘bool Ranking::Racer::operator<(const Ranking::Racer&)’ discards qualifiers [-fpermissive]