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);
object
argument
Polymorphism depends on both the calling object and the argument objects
Node
, Leaf
, or List
visit(Node*)
an empty method that does nothing (a NOP) so a visitor can ignore a particular type of Node