Virtual functions are an important part of (runtime) polymorphism in object-oriented programming (OOP).
Most programming languages, such as JavaScript, PHP and Python, treat all methods as virtual by default[1][2] and do not provide a modifier to change this behavior.
However, some languages provide modifiers to prevent methods from being overridden by derived classes (such as the final and private keywords in Java[3] and PHP[4]).
If it is not "virtual", the method is resolved "early" and selected according to the declared type of the pointer or reference.
Virtual functions allow a program to call methods that don't necessarily even exist at the moment the code is compiled.
This modifier is inherited by all implementations of that method in derived classes, meaning that they can continue to over-ride each other and be late-bound.
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.
However, because many OOP languages do not support multiple inheritance, they often provide a separate interface mechanism.
Object-oriented languages typically manage memory allocation and de-allocation automatically when objects are created and destroyed.
In manual memory management contexts, the situation can be more complex, particularly in relation to static dispatch.