#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
void print1(int val)
{
cout << val << " ";
}
class Print2
{
public:
void operator()(int val)
{
cout<<val<<" ";
}
};
void test()
{
vector<int> v;
for (int i = 0; i < 10; i++)
{
v.push_back(i);
}
for_each(v.begin(), v.end(), print1);
cout << endl;
for_each(v.begin(), v.end(), Print2());
cout << endl;
}
int main()
{
test();
return 0;
}
09-05
285
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)