Mega Code Archive

 
Categories / C++ Tutorial / Deque
 

Print the contents in reverse order using reverse_iterator and functions rbegin() and rend()

#include <deque> #include <iostream> using namespace std; typedef deque<int> INTDEQUE; int main(void) {    INTDEQUE A;    A.push_back(1);    A.push_back(2);    A.push_back(3);    A.push_back(4);    A.push_back(5);    INTDEQUE::reverse_iterator rpi;    for(rpi = A.rbegin(); rpi != A.rend(); rpi++)       cout << *rpi << " ";    cout<< endl; }