Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Dispatch table, table pointer » ?

Aussi appelé : dispatch table · vtable · table pointer

Definition 3.5 University Computer Science — Year 2 · Chapitre 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.
Lire dans le chapitre →