English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
rbegin() returns a reverse iterator at the end of the vector
The syntax for the vector (vector) "v" is:
reverse_iterator ritr = v.rbegin();
It does not contain any parameters.
It returns a reverse iterator pointing to the last element of the vector (vector).
Let's look at a simple example.
#include<iostream> #include<vector> using namespace std; int main() { vector<char> v{'j','a','v','a'}; vector<char>::reverse_iterator rtr; for(rtr=v.rbegin();rtr!=v.rend();rtr++) std::cout<< *rtr; return 0; }
Output:
avaj
In this example, the rbegin() function is used to obtain the reversed string contained in the vector (vector).