数组和集合 / 迭代器

#include <iostream>
#include <vector>
#include <iterator>
#include <sstream>
using namespace std;

vector<int> numbs = {12345};
ostream_iterator<intchar> iter (cout, "; ");
copy(numbs.begin(), numbs.end(), iter);
//printed: "1; 2; 3; 4; 5;"
cout << endl;

stringstream stream;
iter = ostream_iterator<int, char>(stream, "-");
copy(numbs.begin(), numbs.end(), iter);
string str = stream.str();
//str is "1-2-3-4-5-"
cout << "str is '" << str << "'";