Virtual method table

In computer programming, a virtual method table (VMT), virtual function table, virtual call table, dispatch table, vtable, or vftable is a mechanism used in a programming language to support dynamic dispatch (or run-time method binding).

Comment
enIn computer programming, a virtual method table (VMT), virtual function table, virtual call table, dispatch table, vtable, or vftable is a mechanism used in a programming language to support dynamic dispatch (or run-time method binding).
Has abstract
enIn computer programming, a virtual method table (VMT), virtual function table, virtual call table, dispatch table, vtable, or vftable is a mechanism used in a programming language to support dynamic dispatch (or run-time method binding). Whenever a class defines a virtual function (or method), most compilers add a hidden member variable to the class that points to an array of pointers to (virtual) functions called the virtual method table. These pointers are used at runtime to invoke the appropriate function implementations, because at compile time it may not yet be known if the base function is to be called or a derived one implemented by a class that inherits from the base class. There are many different ways to implement such dynamic dispatch, but use of virtual method tables is especially common among C++ and related languages (such as D and C#). Languages that separate the programmatic interface of objects from the implementation, like Visual Basic and Delphi, also tend to use this approach, because it allows objects to use a different implementation simply by using a different set of method pointers. Suppose a program contains three classes in an inheritance hierarchy: a superclass, Cat, and two subclasses, HouseCat and Lion. Class Cat defines a virtual function named speak, so its subclasses may provide an appropriate implementation (e.g. either meow or roar). When the program calls the speak function on a Cat reference (which can refer to an instance of Cat, or an instance of HouseCat or Lion), the code must be able to determine which implementation of the function the call should be dispatched to. This depends on the actual class of the object, not the class of the reference to it (Cat). The class cannot generally be determined statically (that is, at compile time), so neither can the compiler decide which function to call at that time. The call must be dispatched to the right function dynamically (that is, at run time) instead.
Hypernym
Mechanism
Is primary topic of
Virtual method table
Label
enVirtual method table
Link from a Wikipage to another Wikipage
Binary tree dispatch
Bjarne Stroustrup
Branch predictor
Branch table
C++
C++ syntax
Category:Articles with example C++ code
Category:Method (computer programming)
Class (computer programming)
Common Lisp Object System
Compiler
Compile time
Computer programming
Constructor (object-oriented programming)
C Sharp (programming language)
D (programming language)
Default constructor
Delphi (programming language)
Dispatch table
Duck typing
Dylan (programming language)
Dynamic dispatch
G++
GNU Compiler Collection
Hash table
Inheritance (object-oriented programming)
Inline expansion
JavaScript
Julia (programming language)
Just-in-time compilation
Member variable
Memory address
Method (computer programming)
Multiple dispatch
Multiple inheritance
Name binding
Pointer (computer programming)
Programming language
Python (programming language)
Run time (program lifecycle phase)
Single dispatch
Smalltalk
String interning
Subclass (computer science)
Superclass (computer science)
This (computer science)
Thunk (programming)
Type conversion
Virtual function
Virtual inheritance
Visual Basic
SameAs
iGqE
m.03q f3
Q1755692
Tabelle virtueller Methoden
Tabulka virtuálních metod
Virtual method table
Таблица виртуальных методов
Таблиця віртуальних методів
טבלת מתודות וירטואלית
仮想関数テーブル
가상 메소드 테이블
Subject
Category:Articles with example C++ code
Category:Method (computer programming)
WasDerivedFrom
Virtual method table?oldid=1105200646&ns=0
WikiPageLength
14521
Wikipage page ID
930080
Wikipage revision ID
1105200646
WikiPageUsesTemplate
Template:Abbr
Template:Application binary interface
Template:ISBN
Template:Mono
Template:Redirect
Template:Reflist
Template:Short description
Template:Use dmy dates