C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Vector front()It gives a reference to the first element of vector.
Syntax
Consider a vector.Syntax would be: v.front(); Parameter
This function does not contain any parameter. Return valueThis function returns the first element of the vector. Example 1
Let's see a simple example.
#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, front() function displays the first element of language object.
Next TopicC++ Vector
|