algorithmica icon indicating copy to clipboard operation
algorithmica copied to clipboard

Update explanation of virtual dispatch.

Open thoren-d opened this issue 2 years ago • 0 comments

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.

thoren-d avatar Sep 21 '23 06:09 thoren-d