Sign in to follow this  
Joshnathan

iterator error

Recommended Posts

Hi all, this is my code:
for(list<int>::iterator walker = numList.begin(); walker != numList.end(); walker++)


and this is my error: 62 C:\WINDOWS\Desktop\Joshua\Tutorials\STL_Lists_Cpp\STL - Lists\main.cpp using obsolete binding at `walker' I am using dev-c++ 4.9.9.0 Nayone knows what's wrong? Joshua [Edited by - Joshnathan on November 24, 2004 10:44:21 AM]

Share this post


Link to post
Share on other sites
What headers did you include?
How is numList defined?
Have you tried ++walker rather than walker++?

By the way, it's not called a "walker", but an "iterator". [smile]

Share this post


Link to post
Share on other sites
IIRC, that error usually only happens when you declare a variable in a for loop (or something similar) and then reference the variable after the loop is finished. It might help if you changed your loop like:

list<int>::iterator walker;
for(walker = numList.begin(); walker != numList.end(); walker++)

This will keep the variable alive past the end of the for loop.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this