Iterate through STL list

I need to browse the elements of my STL list. I know the iterator will need to be incremented, but could anyone clarify what steps to take?
something like

1
2
3
4
5
6
7
8
9
std::list<int> intList;
for (int i = 0; i < 10; ++i) {
    intList.push_back( 1 << i );
}

std::list<int>::const_iterator iterator;
for (iterator = intList.begin(); iterator != intList.end(); ++iterator) {
    std::cout << *iterator;
}


Maikel

I recommend doing this instead.
1
2
3
for (std::list<int>::const_iterator iterator = intList.begin(), end = intList.end(); iterator != end; ++iterator) {
    std::cout << *iterator;
}
Topic archived. No new replies allowed.