1: //deque02.cpp 3: #include <iostream> 4: #include <string> 5: #include <deque> 6: using namespace std; 8: int main() 9: { 10: cout << "\nThis program illustrates the difference between " 11: "using d[i] and using d.a(i)\nfor access to the " 12: "components of a deque d.\n"; 13: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 15: //Create a deque of five integer values 16: int a[] = {1, 2, 3, 4, 5}; 17: deque<int> d(a, a+5); 19: cout << "\nContents of d using d[i]: "; 20: for (deque<int>::size_type i=0; i<d.size(); i++) 21: cout << d[i] << " "; 22: cout << endl; 23: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 25: cout << "\nContents of d using d.at(i): "; 26: for (deque<int>::size_type i=0; i<d.size(); i++) 27: cout << d.at(i) << " "; 28: cout << endl; 29: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 31: cout << "\nNow let's look at the value of d[6] (if we can).\n"; 32: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 33: cout << "Value of d[6]: " << d[6] << endl; 34: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 36: cout << "\nNow let's look at the value of d.at(6) (if we can).\n"; 37: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 38: cout << "Value of d.at(6): " << d.at(6) << endl; 39: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 40: }