Vtables
Vtables, short for virtual method tables, are a mechanism used by many object-oriented languages to implement dynamic dispatch of virtual functions. A vtable is typically a per-class table of function pointers. Each polymorphic class has an associated vtable, and each object instance carries a hidden pointer to its class's vtable, commonly called a vptr. When a program calls a virtual function through a base-class reference or pointer, the runtime uses the object's vptr to locate the correct function pointer in the vtable and invoke the function corresponding to the object's dynamic type.
Layout and behavior commonly involve entries for all virtual functions declared in the class, including inherited
Multiple inheritance can complicate vtable design. Some compilers implement multiple vtables or a single vtable with
Pros and cons include fast dynamic dispatch and small overhead for non-virtual calls, balanced against increased