?? for_each.cpp
字號:
#include <functional>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
//template <class T>
class out_times_x
{
private:
int multiplier;
public:
out_times_x(const int& k) : multiplier(k) { }
void operator()(const int& x) { cout << x * multiplier << " " << endl; }
};
int main ()
{
int sequence[5] = {1,2,3,4,5};
vector<int> v(sequence, sequence+5);
out_times_x f2(3);
for_each(v.begin(),v.end(),f2); // Apply function
system("pause");
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -