Single Dispatch

A kind of Polymorphism where the dispatch mechanism works against a single dynamic type. Internal Polymorphism is almost always Single Dispatch. This is probably because Single Dispatch can be implemented simply and without introducing unwanted coupling with other types.

This is generally done using a virtual function table. Each function is given an index. Each object contains a hidden pointer to some kind of type object that contains a table that has one function pointer for each virtual function that is implemented by the object. The compiler generates code that dereferences the hidden pointer in the object, indexes into the table and calls the function that it finds.

Contrast with Multiple Dispatch.


See original on c2.com