A virtual function in C ++, by definition, is a function declared with the virtual (immediately or in one of the base classes). It's all.
Now virtual function calls can be resolved statically or dynamically. A dynamically resolved call is a call that is resolved according to the dynamic type of the object used in the call. It's all.
Nothing in the above links to any "function pointers". However, in a typical implementation, to implement the correct behavior of dynamic calls, a table with function pointers (pointing to virtual functions) is used. This table is called "VMT", "VFT" or "vtable".
In other words, a function pointer is an implementation detail commonly used to support dynamic calls to virtual functions.
To illustrate this further, note, for example, that even if a function is virtual, but it is never called dynamically, then there is no need to create any βpointersβ for this function. For this reason, some compilers do not generate VMT for abstract classes, because although these classes have virtual functions, these functions are never called dynamically.
source share