全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Dispatch table, table pointer?

又称: dispatch table · vtable · table pointer

Definition 3.5 University Computer Science — Year 2 · 第 3 章 — Inheritance and Polymorphism

The dispatch table (or vtable) of a class with virtual functions is an array, one per class and built by the compiler, of the addresses of the versions of its virtual functions that apply to that class. Each object of the class holds a table pointer to its class’s table. A virtual call loads the table pointer from the object, loads the address from a fixed position in the table, and calls it.

The two objects of , of two classes. A call s->table->area(s), or its C++ form s->area(), follows the object’s table pointer to its class’s table, takes the address at the position reserved for area, and calls that function with the object.
The two objects of Listing 3.7, of two classes. A call s->table->area(s), or its C++ form s->area(), follows the object’s table pointer to its class’s table, takes the address at the position reserved for area, and calls that function with the object.
在原文中阅读 →