IteratorPattern.cpp 331 B

12345678910111213141516
  1. #include <iostream>
  2. #include "Aggregate.h"
  3. #include "Iterator.h"
  4. using namespace std;
  5. int main() {
  6. Aggregate* ag = new ConcreteAggreaget();
  7. Iterator *it = new ConcreteIterator(ag, 0);
  8. for (; !(it->IsDone()); it->Next()) {
  9. cout << it->CurrentItem() << endl;
  10. }
  11. delete it;
  12. delete ag;
  13. return 0;
  14. }