#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
template <typename T>
class sum//二元函数对象
{
public:
T operator()(T &t1, T &t2)//
{
return t1 + t2;
}
};
void printFun(vector<int> &obj)
{
for (vector<int>::iterator it = obj.begin(); it != obj.end(); it++)
{
cout << *it << " ";
}
cout << endl;
}
void pt(int &a)
{
cout << a << " ";
}
template <typename T>
bool Mycmp(T &t1, T &t2)
{
if (t1 > t2) return true;
else return false;
}
int main()
{
vector<int> v1, v2, v3;
for (size_t i = 0; i < 3; i++)
{
v1.push_back(2 * i + 1);
v2.push_back(2 * i);
}
printFun(v1);
printFun(v2);
//transform 函数对象参数一般不是引用,必须有返回值
//for_each 函数对象参数一般 是引用, 没有返回值
//使用二元函数对象
v3.resize(3);
transform(v1.begin(), v1.end(),