关系仿函数-大于
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
class Print
{
public:
void operator()(int i)
{
cout << i << endl;
}
};
int main()
{
vector<int> v;
v.push_back(1);
v.push_back(5);
v.push_back(3);
sort(v.begin(), v.end(), greater<int>());
for_each(v.begin(), v.end(), Print());
return 0;
}
$ ./a.out
5
3
1