Reverse Iterator

#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
int main()
{
    vector < int > x;
    vector < int >::reverse_iterator i;;
    x.push_back(1);
    x.push_back(2);
    x.push_back(3);
    x.push_back(4);
    for(i=x.rbegin(); i!=x.rend();i++)
    {
                     cout<<*i<<endl;
    }
    
    system("pause");
    return 0;
}


This is the output:
4
3
2
1

0 comments:

Post a Comment