#include <iostream> #include <string> #include <iterator> #include <vector> #include <algorithm> using namespace std; struct fun_int_to_str { string operator()(int iPara) { char szBuf[32] = {0}; itoa(iPara, szBuf, 10); return szBuf; } }; template<class T> struct fun_print { void operator()(T &cont) { cout << cont << " "; } }; int main() { vector<int> vecInt; vecInt.push_back(1345); vecInt.push_back(26723); vecInt.push_back(357235); vecInt.push_back(454345); vecInt.push_back(45575000); for_each(vecInt.begin(), vecInt.end(), fun_print<int>()); cout << endl; vector<string> vecStr; transform(vecInt.begin(), vecInt.end(), back_inserter(vecStr), fun_int_to_str()); for_each(vecStr.begin(), vecStr.end(), fun_print<string>()); return 0; }