SE450
:
Double Dispatch Example
[48/55]
DirectoryNode node = new DirectoryNode(new File(".."));
node.accept(new PrintVisitor());
node
is a
DirectoryNode
Polymorphism:
node.accept
calls
DirectoryNode.accept
That method calls
v.visitDirectoryNode
v
is a
PrintVisitor
Polymorphism: calls
PrintVisitor.visitDirectoryNode
Two polymorphic calls determine
node type
visitor type