vector-end

////////////////////////////////////////
//      2018/04/16 9:46:45
//      vector-end

#include <iostream>
#include <vector>
#include <iterator>
#include <numeric>

using namespace std;

int main(){
    vector<int> v(5);
    iota(v.begin(),v.end(), 1);

    vector<int>::iterator it = v.begin();
    while (it != v.end()){
        cout << *(it++) << " ";
    }
    cout << endl;

    // last element of the vector
    it = v.end() - 1;
    cout << *it << endl;
    return 0;
}

/*
OUTPUT:
    1 2 3 4 5
    5
*/ 
原文地址:https://www.cnblogs.com/laohaozi/p/12538048.html