|
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.
|