| 4 | #include <algorithm> // std::copy |
| 5 | |
| 6 | int main () { |
| 7 | std::vector<int> foo,bar; |
| 8 | for (int i=1; i<=5; i++) |
| 9 | { foo.push_back(i); bar.push_back(i*10); } |
| 10 | |
| 11 | std::copy (bar.begin(),bar.end(),back_inserter(foo)); |
| 12 | |
| 13 | std::cout << "foo contains:"; |
| 14 | for ( std::vector<int>::iterator it = foo.begin(); it!= foo.end(); ++it ) |
| 15 | std::cout << ' ' << *it; |
| 16 | std::cout << '\n'; |
| 17 | |
| 18 | return 0; |
| 19 | } |