Wednesday, May 11, 2011

STL list iterator example

Here's a simple STL list iterator example code in c++. It just traverses the items in a given STL list container. [STL list iterator example]

An Example of Iterating Through a List

void print( list<int> a)
{
for(list<int>::iterator ai=a.begin(); ai!=a.end(); ++ai)
cout << *ai << " ";
cout << endl;
cout << "----------------"<<endl;
}