C++ Vector front
It provides a reference to the initial element of the vector.
Syntax
Consider a vector.Syntax would be:
Example
v.front();
Parameter
This function does not contain any parameter.
Return value
This function retrieves the initial element from the vector.
Example 1
Let's see a simple example.
Example
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<string> language{"java","C","C++"};
cout<<language.front();
return 0;
}
Output:
In this instance, the front method showcases the initial element of the language object.