English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Returns an iterator to the end element of the current vector container.
The syntax of the vector (vector) v is:
iterator it = v.end()
It does not contain any parameters.
It is the iterator of the last element.
Let's look at a simple example.
#include<iostream> #include<vector> using namespace std; int main() } vector<int> v{10,20,20,40}; vector<int>::iterator it; for(it=v.begin();it!=v.end();it++) cout<<*it<<" "; return 0; }
Output:
10 20 20 40
In this example, the elements of the vector (vector) are iterated using the begin() and end() functions.
Let's look at another simple example.
#include<iostream> #include<vector> using namespace std; int main() } vector<string> v{"Welcome","to","w3codebox"}; vector<string>::iterator it; for(it=v.begin();it!=v.end();it++) cout<<*it<<" "; return 0; }
Output:
Welcome to w3codebox
In this example, the begin() and end() functions have been used to iterate over the string in the vector (vector).