Iterator.h 468 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include "Aggregate.h"
  3. class Iterator {
  4. public:
  5. Iterator();
  6. virtual ~Iterator();
  7. virtual void First() = 0;
  8. virtual void Next() = 0;
  9. virtual bool IsDone() = 0;
  10. virtual Object CurrentItem() = 0;
  11. };
  12. class ConcreteIterator :public Iterator {
  13. public:
  14. ConcreteIterator(Aggregate *ag, int idx /* = 0 */);
  15. void First();
  16. void Next();
  17. bool IsDone();
  18. Object CurrentItem();
  19. private:
  20. Aggregate* _ag;
  21. int _idx;
  22. };