begin(): It returns the read or write an iterator that points to the first element of the vector.
Syntax:
iterator vecName.begin()
File: stl_vector.h
Example:
vec = {1,2,3,4}
iterator it = vec.begin() => it returns the iterator to the 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>::iterator it = vec.begin();cout << *it << "\n";return 0;}
No comments:
Post a Comment