front(): It is a build-in function in STL. It returns a read/write reference to
the data at the first element of the vector.
Parameter: No parameter is required for this function.
Syntax:
vecName.front()
For Example:
vec = {1,2,3,4}
vec.front() = > It returns the first element (i.e 1)
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){vector<int> vec = {1, 2, 3, 4};//print the first element of the vectorcout << vec.front() << "\n";return 0;}
No comments:
Post a Comment