Описание тега visitor

The Visitor design pattern is a way of separating an algorithm from an object structure on which it operates. It is one of the Gang of Four's behavioral design patterns. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

In essence, the Visitor pattern lets you define a new operation without changing the classes of the elements on which it operates; instead, one creates a visitor class that implements all of the appropriate specializations of the virtual function. The visitor takes the instance reference as input, and implements the goal through double dispatch.

This is one of the Gang of Four's behavioral design-patterns, first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

More information is available on Wikipedia.