stl-function-adaptor.cc
来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架>」· CC 代码 · 共 34 行
CC
34 行
// Filename: STL-function-adaptor.cc// Use of the function adaptor bind2nd#include <iostream>#include <algorithm>#include <functional>#include <string>using namespace std;template <class Iter>void display(Iter fst, Iter lst, const char* ttl) { cout << ttl << endl; while ( fst != lst) cout << *fst++ << '\t'; cout << endl;}int main() { int data[3] = { 9, 10, 11}; display(data, data + 3, "Original values"); transform(data, data + 3, data, bind2nd(multiplies<int>(), 2)); display(data, data + 3, "New values");}/*outOOP> gpp STL-function-adaptor.ccOOP> a.outOriginal values9 10 11New values18 20 22OOP>*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?