stl-function-adaptor.cc.svn-base

来自「QT方面的开发」· SVN-BASE 代码 · 共 34 行

SVN-BASE
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 + -
显示快捷键?