Can anyone explain why the author of this tutorial initially uses rbegin() but subsequently uses begin()?
I thought the objective here was to be able to count backwards through the use of an iterator.
Code:
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> myvector (5); // 5 default-constructed ints
int i=0;
std::vector<int>::reverse_iterator rit = myvector.rbegin();
for (; rit!= myvector.rend(); ++rit)
*rit = ++i;
std::cout << "myvector contains:";
for (std::vector<int>::iterator it = myvector.begin(); it != myvector.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}