cbegin(): It returns the read-only (constant) iterator that points to the first element
in the vector.
Syntax:
vector<data_type> ::const_iterator iteratorName = vecName.cbegin()
File: stl_vector.h
For Example:
vec = {1,2,3,4}
vec.cbegin() => It returns the iterator to first element (i.e 1)
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){vector<int> vec = {1, 3, 4, 5};vector<int>::const_iterator it = vec.cbegin();cout << *it << "\n";return 0;}
No comments:
Post a Comment