Difference betwen Visitor pattern & Double Dispatch

前端 未结 5 1668
逝去的感伤
逝去的感伤 2020-11-30 00:05

I am reading about visitor pattern, and it appears the same like Double Dispatch. Is there any difference between the two. Do the two terms means the same thing.

re

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 00:10

    Double dispatch is a technical problem, which can, depending on the language, be solved in different manners—some languages support double dispatch directly. The visitor pattern is a pattern which can be used to solve different problems. In the case of C++, it's the most frequent (but not the only) solution used for double dispatch, but it's not used exclusively for that, and it can be useful even in languages that do support double dispatch.

提交回复
热议问题