fixup! WIP: posts: add mutiple-dispatch-in-c++

This commit is contained in:
Bruno BELANYI 2022-11-02 15:52:38 +01:00
parent cb9545769d
commit 70f99f21fa

View file

@ -107,11 +107,11 @@ and can be used for testing, etc...
## Double dispatch through the Visitor pattern
Sometimes single dispatch is not enough, such as in the collision example at
the beginning of this article. In cases where a computation depends on the
dynamic type of *two* of its values, we can make use of double-dispatch by
calling a virtual method on the first value, which will call a virtual method
on the second value.
Sometimes single dispatch is not enough, such as in the collision example at the
beginning of this article. In cases where a computation depends on the dynamic
type of *two* of its values, we can make use of double-dispatch by leveraging
the Visitor design pattern. This is done by calling a virtual method on the
first value, which itself will call a virtual method on the second value.
Here's a commentated example: