C++ Vector front
It gives a reference to the first element of vector.
Syntax
Consider a vector.Syntax would be:
Example
v.front();
Parameter
This function does not contain any parameter.
Return value
This function returns the first element of 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 example, front function displays the first element of language object.