Source of deque09.cpp


  1: //deque09.cpp

  3: #include <iostream>
  4: #include <deque>
  5: using namespace std;

  7: int main()
  8: {
  9:     cout << "\nThis program illustrates the member functions "
 10:         "front() and back().";
 11:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');

 13:     int a[] = {2, 4, 6, 8, 10};
 14:     deque<int> d(a, a+5);
 15:     cout << "\nHere are the deque contents:\n";
 16:     deque<int>::iterator p = d.begin();
 17:     while (p != d.end()) cout << *p++ << " ";  cout << endl;
 18:     cout << "Press Enter to continue ... ";  cin.ignore(80, '\n');

 20:     cout << "\nThe first value in the deque is "
 21:         << d.front() << ".\n";
 22:     cout << "The last value in the deque is "
 23:         << d.back() << ".\n";
 24:     cout << "Press Enter to continue ... ";  cin.ignore(80, '\n');
 25: }