Difference betwen Visitor pattern & Double Dispatch

前端 未结 5 1671
逝去的感伤
逝去的感伤 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:22

    From Wikipedia:

    the visitor pattern simulates double dispatch in a conventional single-dispatch object-oriented language such as Java, Smalltalk, and C++.

    Also from Wikipedia:

    The problem described above can be resolved by simulating double dispatch, for example by using a visitor pattern.

提交回复
热议问题