in reply to Iterator as a Class or Object Method
Making the iterator a method specific to any particular class or instance of class is against the basic idea of OO. Iteration itself is a concept detached from any specific existance. To make it a method simply restricts its reusability.
If you are so fond of making this OO, there should be an Iterator base class, which defines certain common methods like next(). This class should NOT be a sub class of any of your other classes.
You can inherit from this base class and add methods that are specfic to your needs.
|
|---|