11 The Iterator and Visitor Design Patterns

This chapter covers

  • The Iterator Design Pattern
  • The Visitor Design Pattern

The two design patterns in this chapter provide models for applications that must flexibly access data stored in various data structures, such as vectors, lists, and trees. The example applications continue the theme of generating sports reports.

The Iterator Design Pattern enables a single algorithm to iterate over multiple sequential collections of objects without needing to know how the collections are implemented. Our first example application is modeled from this design pattern. The application’s algorithm can generate ...

Get Object-Oriented Software Design in C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.