vector::end() 函数的语法
vector::end();
参数: none——它什么都不接受。
返回值: iterator– 它返回一个指向向量的 past-the-end 元素的迭代器。
实际上Vector中的begin和end函数是左闭右开的区间。
例:
Input:
vector<int> vector1{ 1, 2, 3, 4, 5 };
Function call:
vector<int>::iterator it;
it = vector1.begin();
cout << *it << endl;
it = vector1.end()-1;
cout << *it << endl;
Output:
1
5