O'Reilly logo

Design Patterns: Elements of Reusable Object-Oriented Software by John Vlissides, Ralph Johnson, Richard Helm, Erich Gamma

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Foundation Classes

This appendix documents the foundation classes we use in the C++ sample code of several design patterns. We’ve intentionally kept the classes simple and minimal. We describe the following classes:

  • List, an ordered list of objects.

  • Iterator, the interface for accessing an aggregate’s objects in a sequence.

  • ListIterator, an iterator for traversing a List.

  • Point, a two-dimensional point.

  • Rect, an axis-aligned rectangle.

Some newer C++ standard types may not be available on all compilers. In particular, if your compiler doesn’t define bool, then define it manually as

typedef int bool;
const int true = 1;
const int false = 0;

List

The List class template provides a basic container for storing an ordered list of objects. List

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required