C++ vector rbegin() function
Example
List the items of a vector in reverse:
vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
vector<string>::reverse_iterator it;
for (it = cars.rbegin(); it != cars.rend(); ++it) {
cout << *it << "\n";
}
Try it Yourself »
Definition and Usage
The rbegin()
function returns a reverse iterator pointing to the last element in a vector.
Syntax
vector.rbegin();
Parameter Values
None.
Technical Details
Returns: | A reverse iterator pointing to the last element in the vector. |
---|
Related Pages
Read more about vectors in our Vector Tutorial.
Read more about iterators in our Iterators Tutorial.