Dynamic dispatch, selecting which function is called at runtime based on the type of some object (a.k.a. polymorphism), is one of the defining traits of object-oriented programming. While many languages support dynamic dispatch, each in different ways with its own trade-offs, C does not. However, you can implement it in the style of any programming language that does support it. This chapter illustrates two such styles: virtual function tables and fat pointers.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Dynamic Dispatch

  • Paul J. Lucas

摘要

Dynamic dispatch, selecting which function is called at runtime based on the type of some object (a.k.a. polymorphism), is one of the defining traits of object-oriented programming. While many languages support dynamic dispatch, each in different ways with its own trade-offs, C does not. However, you can implement it in the style of any programming language that does support it. This chapter illustrates two such styles: virtual function tables and fat pointers.