List iterator for certain type list : list iterator « list « C++ Tutorial






#include <iostream>
#include <list>

using namespace std;
typedef list<int> LISTINT;

int main(void)
 {
   LISTINT listOne;
   LISTINT::iterator i;

   listOne.push_front (2);
   listOne.push_front (1);
   listOne.push_back (3);

   for (i = listOne.begin(); i != listOne.end(); ++i)
     cout << *i << " ";
   cout << endl;

   for (i = listOne.end(); i != listOne.begin(); --i)
     cout << *i << " ";
   cout << endl;

 }








17.9.list iterator
17.9.1.Use iterator to loop through all elements in a list
17.9.2.Use iterator to change all elements in a list
17.9.3.Loop through list back and forth
17.9.4.Use reverse_iterator and iterator with list
17.9.5.iterator of list integers
17.9.6.List iterator for certain type list
17.9.7.Move list iterator using ++