Use ostream_iterator for string
#include <iostream>
#include <list>
#include <iterator>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
list<string> listObject;
ostream_iterator<string> out_it(cout);
listObject.push_back("Stream ");
listObject.push_back("iterators ");
listObject.push_back("are ");
listObject.push_back("useful.");
copy(listObject.begin(), listObject.end(), out_it);
return 0;
}
Related examples in the same category