output()output() to list structure and handlingNode, Leaf, and List, and any of their derived classesAdd operations to classes without changing them
visit() is passed a Node*, only the visit(Node*) is called, even if the parameter is a Leaf or List| single dispatch | Polymorphism depends on the calling object only |
| multiple dispatch | Polymorphism depends on both the calling object and the argument objects |
Polymorphism depends on the calling object only
object->operation(argument);objectargumentPolymorphism depends on both the calling object and the argument objects
Node, Leaf, or Listvisit(Node*) an empty method that does nothing (a NOP) so a visitor can ignore a particular type of Node