1: //vector09.cpp
3: #include <iostream>
4: #include <vector>
5: using namespace std;
7: int main()
8: {
9: cout << "\nThis program illustrates the member functions "
10: "front(), back().";
11: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
13: int a[] = {2, 4, 6, 8, 10};
14: vector<int> v(a, a+5);
15: cout << "\nHere are the vector contents:\n";
16: vector<int>::iterator p = v.begin();
17: while (p != v.end()) cout << *p++ << " "; cout << endl;
18: cout << "Press Enter to continue ... "; cin.ignore(80, '\n');
20: cout << "\nThe first value in the vector is "
21: << v.front() << ".\n";
22: cout << "The last value in the vector is "
23: << v.back() << ".\n";
24: cout << "Press Enter to continue ... "; cin.ignore(80, '\n');
25: }