algorithmica
algorithmica copied to clipboard
Update explanation of virtual dispatch.
The existing description is not how I see it working in any of the top modern compilers at the moment.
An example in clang: Godbolt
The implementations of speak() are different sizes, and the call to speak() dereferences the vtable, rather than computing an offset.
Also made a small correction to the example code, which forgot to have Cat and Dog inherit from Animal.