Virtual function

virtualvirtual methodvirtual functionsPure virtual functionvirtual destructorvirtual methodsabstractpure virtualpure virtual functionspure virtual procedures
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.wikipedia
68 Related Articles

C++

C++ programming languageC++98C with Classes
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.
New features were added, including virtual functions, function name and operator overloading, references, constants, type-safe free-store memory allocation (new/delete), improved type checking, and BCPL style single-line comments with two forward slashes.

Object Pascal

DelphiDelphi programming languageDCU
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.
These were inspired by the ISO working draft for object-oriented extensions, but many of the differences from Turbo Pascal's dialect (such as the draft's requirement that all methods be virtual) were ignored.

Abstract type

abstract classabstractabstract classes
A pure virtual function or pure virtual method is a virtual function that is required to be implemented by a derived class if the derived class is not abstract.

Polymorphism (computer science)

polymorphismpolymorphictype polymorphism
This concept is an important part of the (runtime) polymorphism portion of object-oriented programming (OOP).
Polymorphism can be distinguished by when the implementation is selected: statically (at compile time) or dynamically (at run time, typically via a virtual function).

Virtual method table

vtablevirtual tablevirtual function table
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.

Destructor (computer programming)

destructordestructorsDestructor (computer science)
Languages differ in their behaviour while the constructor or destructor of an object is running.
In inheritance hierarchies, the declaration of a virtual destructor in the base class ensures that the destructors of derived classes are invoked properly when an object is deleted through a pointer-to-base-class.

Inheritance (object-oriented programming)

inheritancesuperclasssubclass
A subclass of an abstract class can only be instantiated directly if all inherited pure virtual methods have been implemented by that class or a parent class.
If the superclass method is a virtual method, then invocations of the superclass method will be dynamically dispatched.

Protocol (object-oriented programming)

interfaceinterfacesprotocols
In C++ interfaces are known as abstract base classes and implemented using pure virtual functions.

Method (computer programming)

methodsmethodabstract method
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.
C++ also has the concept of virtual functions which are member functions that can be overridden in derived classes and allow for dynamic dispatch.

Object-oriented programming

object-orientedobject orientedobject-oriented programming language
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated. This concept is an important part of the (runtime) polymorphism portion of object-oriented programming (OOP).

Method overriding

overrideoverriddenoverriding
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.

Subroutine

functionfunctionssubroutines
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.

Dynamic dispatch

single dispatchFat pointerruntime polymorphism
In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.

Pointer (computer programming)

pointerpointerspointer arithmetic
In object-oriented programming, when a derived class inherits from a base class, an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type.

Reference (computer science)

referencereferencesHandle
In object-oriented programming, when a derived class inherits from a base class, an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type.

Type signature

method signaturesignaturetype annotation
Pure virtual methods typically have a declaration (signature) and no definition (implementation).

Class implementation file

implementation bodybody of the methodsimplementation
Pure virtual methods typically have a declaration (signature) and no definition (implementation).

Interface (Java)

interfacesinterfaceJava interface
Pure virtual functions can also be used where the method declarations are being used to define an interface - similar to what the interface keyword in Java explicitly specifies.

Design pattern

design patternspatternpatterns
In such a design pattern, the abstract class which serves as an interface will contain only pure virtual functions, but no data members or ordinary methods.

Multiple inheritance

diamond problemmulti-inheritanceDiamond inheritance problem
In C++, using such purely abstract classes as interfaces works because C++ supports multiple inheritance.

Java (programming language)

JavaJava programming languageJava language
An example is the Java programming language.

Constructor (object-oriented programming)

Constructor (computer science)constructorscopy constructor
Languages differ in their behaviour while the constructor or destructor of an object is running.

Software design pattern

design patterndesign patternspattern
While it is recommended that virtual function calls in constructors should be avoided for C++, in some other languages, for example C# and Java, the derived implementation can be called during construction and design patterns such as the Abstract Factory Pattern actively promote this usage in languages supporting the ability.

Abstract factory pattern

abstract factory
While it is recommended that virtual function calls in constructors should be avoided for C++, in some other languages, for example C# and Java, the derived implementation can be called during construction and design patterns such as the Abstract Factory Pattern actively promote this usage in languages supporting the ability.