View Single Post
  #1 (permalink)  
Old 08-04-2007, 08:07 PM
Harb Harb is offline
Member
 
Join Date: Aug 2007
Posts: 2
Harb is on a distinguished road
Implementing Iterator
Hello.
I'm trying to make a class that I want to be able to use in a "foreach" statement. My question is, how does the object know when to start over in a new iteration? (i.e. next time I want to iterate through the collection)

I'm using a counter with the next() method to keep track of which object it is currently on, but I'm unsure of which method is supposed to reset the counter to start over from the beginning.
Reply With Quote
Sponsored Links