若要檢視英文版的文章，請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上，即可在快顯視窗顯示英文原文。 譯文 原文

reverse_iterator::reverse_iterator

Visual Studio 2015

語法

```
reverse_iterator( );
explicit reverse_iterator(   RandomIterator _Right);template<class Type>   reverse_iterator(      const reverse_iterator<Type>& _Right);
```

_Right

備註

&*(reverse_iterator ( i ) ) == &*( i – 1 ).

範例

```// reverse_iterator_reverse_iterator.cpp
// compile with: /EHsc
#include <iterator>
#include <algorithm>
#include <vector>
#include <iostream>

int main( )
{
using namespace std;
int i;

vector<int> vec;
for ( i = 1 ; i < 6 ; ++i )
{
vec.push_back ( i );
}

vector <int>::iterator vIter;
cout << "The vector vec is: ( ";
for ( vIter = vec.begin ( ) ; vIter != vec.end ( ); vIter++)
cout << *vIter << " ";
cout << ")." << endl;

vector <int>::reverse_iterator rvIter;
cout << "The vector vec reversed is: ( ";
for ( rvIter = vec.rbegin( ) ; rvIter != vec.rend( ); rvIter++)
cout << *rvIter << " ";
cout << ")." << endl;

vector <int>::iterator pos;
pos = find ( vec.begin ( ), vec.end ( ), 4 );
cout << "The iterator pos = " << *pos << "." << endl;

vector <int>::reverse_iterator rpos ( pos );
cout << "The reverse_iterator rpos = " << *rpos
<< "." << endl;
}
```

輸出

```The vector vec is: ( 1 2 3 4 5 ).
The vector vec reversed is: ( 5 4 3 2 1 ).
The iterator pos = 4.
The reverse_iterator rpos = 3.
```