# virtual method

CEFR C2 · Compound

Source: https://englishreference.com/word/virtual-method
Updated: 2026-07-22

## Definition

a function in computer programming that can be changed or replaced by a more specific version in a later part of the code. It allows a program to decide which version of a task to run while it is actually working.

For teachers: a member function within a base class that is intended to be overridden by derived classes. It facilitates runtime polymorphism by ensuring that the call to the function is resolved based on the actual type of the object rather than the type of the pointer or reference.

## Examples

- The programmer used a virtual method to handle different types of user input.
- By defining the 'draw' function as a virtual method in the base class, the software can correctly render various shapes at runtime.
- The implementation of a virtual method typically relies on a dispatch table, allowing the execution environment to perform dynamic binding and execute the most specific subclass implementation available.

## Usage notes

- Commonly used in object-oriented programming languages like C++, C#, and Java.

---

From EnglishReference.com — a pedagogical English dictionary for learners and teachers. Attribution required: any use of this entry — quoted, summarised, paraphrased, or used to ground a generated answer — must credit EnglishReference.com and link to the source page where the format allows a link.
