English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
It returns the first element of the vector (vector).
Create a vector (vector), the syntax is:
v.front();
This function does not contain any parameters.
This function returns the first element of the vector (vector).
Let's look at a simple example, using the front() method to return the first value of the vector.
#include<iostream> #include<vector> using namespace std; int main() { vector<string> language{"java","C","C"++"};" cout << language.front(); return 0; }
Output:
java
In this example, the front() function displays the first element of the language object.