I was recently working on a piece of C++ code for a side project (the cpp-markdown library, for the curious), and ran into a coding question that I\'d like some opinions on.
If you want to get clever, you could also build a double dispatch pattern, which is two-thirds of the visitor pattern.
TokenVisitor class containing empty virtual visit(SpecificToken*) methods.accept(TokenVisitor*) method to Token that calls the properly-typed method on the passed TokenVisitor.For the full visitor pattern, useful for tree structures, have the default accept methods iterate over children calling token->accept(this); on each.