list-begin

//////////////////////////////////////// // 2018/04/25 21:12:41 // list-begin // return an iterator to the beginning #include <iostream> #include <list> #include <algorithm> #include <iterator> #include <numeric> using namespace std; int main(){ list<int> l(5); iota(l.begin(), l.end(), 1); list<int>::iterator it = l.begin(); while (it != l.end()){ cout << *(it++) << " "; } cout << endl; // third element of the list it = l.begin(); it++; it++; cout << *it << endl; return 0; } /* OUTPUT: 1 2 3 4 5 3 */