Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Dispatch table, table pointer?

Ook bekend als: dispatch table · vtable · table pointer

Definition 3.5 University Computer Science — Year 2 · Hoofdstuk 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.
Lees in het hoofdstuk →