<<< Visitor, cont.     Index     Visitor Benefits >>>

67. Visitor Structure

    Visitor UML Class Diagram
  • The Visitor can visit objects that don't have a common parent class.

  • Although the ConcreteElement nodes may represent unrelated classes, they all should derive from a common Element base.

  • The client instantiates a ConcreteVisitor.

  • The traversal algorithm invokes Element::accept(Visitor) for each node.

  • The ConcreteElement calls Visitor::visit(ConcreteElement).

  • The ConcreteVisitor now uses the ConcreteElement interface to carry out node-specific tasks.

<<< Visitor, cont.     Index     Visitor Benefits >>>