二元谓词
作者:互联网
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Print
{
public:
void operator()(int i)
{
cout << i << endl;
}
};
class Compare
{
public:
bool operator()(int a, int b)
{
return a > b;
}
};
int main()
{
vector<int> v;
v.push_back(1);
v.push_back(5);
v.push_back(3);
sort(v.begin(), v.end(), Compare());
for_each(v.begin(), v.end(), Print());
return 0;
}
$ ./a.out
5
3
1
标签:end,二元,int,back,Print,谓词,push,include 来源: https://www.cnblogs.com/zhangxuechao/p/16536614.html