Standard C++ Library Class Reference
copy(v1.begin(),v1.end(),back_inserter(v4));
//
// Copy all four to cout
//
ostream_iterator<int> out(cout," ");
copy(v1.begin(),v1.end(),out);
cout << endl;
copy(v2.begin(),v2.end(),out);
cout << endl;
copy(v3.begin(),v3.end(),out);
cout << endl;
copy(v4.begin(),v4.end(),out);
cout << endl;
return 0;
}
Output :
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Warning
If your compiler does not support default template parameters then you need to always supply the
Allocator template argument. For instance you'll have to write:
vector <int, allocator>
instead of:
vector <int>