crbegin(): It is an in-build function in STL of C++. It basically returns the read-only (constant) reverse iterator that points to the last element in the vector.
Note: Iteration is done in the reverse element order.
Syntax:
vector<data_type>::const_reverse_iterator it = vecName.crbegin()
File: stl_vector.h
For Example:
vec = {1,2,3,4,5}
vec.crbegin() = > It points to the last element (i.e 5)
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){vector<int> vec = {1, 2, 3, 4, 5};vector<int>::const_reverse_iterator it = vec.crbegin();cout << *it << "\n";return 0;}
No comments:
Post a Comment