1: //TestStuff20160208.cpp
3: #include <iostream>
4: #include <string>
5: #include <vector>
6: #include <algorithm>
7: using namespace std;
9: int main(int argc, char* argv[])
10: {
11: int odds[] = { 1, 3, 5, 7, 9 };
12: vector<int> v1(odds, odds + 5);
13: cout << "\nHere are the contents of v1:\n";
14: for (vector<int>::size_type i = 0; i < v1.size(); i++)
15: cout << v1.at(i) << " ";
16: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
18: //The destination of a copy must be large enough
19: //to receive the copied values:
20: vector<int> v2(5);
21: cout << "\nHere are the contents of v2:\n";
22: for (vector<int>::size_type i = 0; i < v2.size(); i++)
23: cout << v2.at(i) << " ";
24: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
26: copy(v1.begin(), v1.end(), v2.begin()+2);
27: for (vector<int>::size_type i = 0; i<v2.size(); i++)
28: cout << v2.at(i) << " ";
29: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
31: }