#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
class MyClass : public binary_function<MyClass, MyClass, bool> {
public:
int id;
bool operator()(const MyClass& x, const MyClass& y) const {
return x.id >= y.id;
}
friend ostream& operator<<(ostream& o, const MyClass& x) {
o << x.id;
return o;
}
};
int main()
{
vector<MyClass> vector1(100);
for (int i = 0; i != 100; ++i)
vector1[i].id = 100 - i - 1;
sort(vector1.begin(), vector1.end(), not2(MyClass()));
for (int k = 0; k != 100; ++k)
cout << vector1[k].id << " ";
return 0;
}
|