<<< Visitor Benefits     Index     Patterns and You >>>

69. Visitor Sample

  • The Visitor ( download ) sample illustrates this design pattern as follows:

    • Car is a complex object with Body, Engine, and Wheel parts, all derived from the CarElement base.

    • CarElementVisitor is an abstract visitor interface, declaring operations to visit Body, Engine, and Wheels.

    • The CarElementPrintVisitor and CarElementDoVisitor are concrete visitors, each implementing the required visit() operation for every car element.

    Visitor Sample

<<< Visitor Benefits     Index     Patterns and You >>>