bbaja42
bbaja42

Reputation: 2169

Difference between double dispatch and visitor pattern in Java and C++

Is there any difference between double dispatch and visitor pattern?

I'm working with Java and C++ and wondering if there is any split between the two.

Upvotes: 1

Views: 498

Answers (1)

anon
anon

Reputation:

The visitor pattern is a means of adding a new operation to existing classes. Double dispatch is a means of dispatching function calls with respect to two (or, when generalised, more) polymorphic types, rather than a single polymorphic type, which is what languages like C++ and Java support directly.

Upvotes: 2

Related Questions