Vector Rbegin Function - C++ Programming Tutorial
C++ Course / STL Vector / Vector Rbegin Function

Vector Rbegin Function

BLUF: Mastering Vector Rbegin Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Vector Rbegin Function

C++ is renowned for its efficiency. Learn how Vector Rbegin Function enables low-level control and high-performance computing in the tutorial below.

C++ Vector rbegin

The rbegin method stands for 'reverse begin' and is employed to reference the final element of the vector.

Syntax

Consider a vector 'v' and syntax would be :

Example

reverse_iterator ritr=v.rbegin();

Parameter

It does not contain any parameter.

Return value

It provides a reverse iterator that points to the final element within the vector.

Example

Let's see a simple example.

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:

In this instance, the rbegin method is employed to retrieve the reversed string stored within the vector.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience