Re:What can we learn from how compilers are designed?
by yorwba on Saturday March 17, 2018 @01:28AM
(#16605720)
The static type of both c and t is Vehicle, but by dynamic multiple dispatch Car::Collide(Truck) is selected. That's not how C++ works, but the example was exactly about illustrating how C++ doesn't work.
Multiple dispatch is typically meant to be purely dynamic in meaning, as wiki puts it:
> Multiple dispatch or multimethods is a feature of some programming languages in which a function or method can be dynamically dispatched based on the run-time (dynamic) type or, in the more general case some other attribute, of more than one of its arguments.[1]
(https://en.wikipedia.org/wiki/Multiple_dispatch)