• Advertisement
Sign in to follow this  

iterator error

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement