Virtual method
A virtual method is an overridable method whose implementation is selected at runtime according to the receiver object's dynamic type.
Learn C++ by Example
A virtual function is a C++ member function whose implementation can be selected according to the object's dynamic type through polymorphic dispatch.
- How it is used
- Uses virtual methods to let different blob types compete through one common race interface.
- How deep it goes
- Explains pure virtual methods, overriding, v-table dispatch, destructor safety, and pointer-based use without detailing compiler-generated layouts.
- Examples
- Demonstrates StepperBlob, RandomBlob, a Blob race, assertions, random distributions, and a zero-valued test generator.
- What you can do after
- Build it from scratch by defining a polymorphic Blob interface and implementing interchangeable derived classes with tested behavior.
100 C++ Mistakes and How to Avoid Them
A virtual function is a C++ member function whose implementation can be dynamically selected through an object of a derived class.
- How it is used
- Uses virtual methods to customize inherited behavior and preserve polymorphic operations across base-class interfaces.
- How deep it goes
- Explains dispatch through pointers or references, override checking, and destructor consequences, but does not detail dispatch internals.
- Examples
- Demonstrates Shape, Square, and Circle examples containing a misspelled override and a missing virtual destructor.
- What you can do after
- Apply polymorphism with compiler-checked overrides and destruct safely through base-class pointers.
Read how 100 C++ Mistakes and How to Avoid Them explains virtual method →
The Quick Python Book, Fourth Edition
A virtual method is a method whose implementation can be dynamically selected according to the class of the object on which it is invoked.
- How it is used
- Uses superclass lookup to share methods across related Python classes while permitting subclass-specific replacements.
- How deep it goes
- Defines dynamic method lookup and inheritance, but stops short of implementation-level dispatch details.
- Examples
- Demonstrates inherited movement through Shape, Circle, coordinates, and a concrete c.move(3, 4) call.
- What you can do after
- Evaluate inherited method behavior by tracing subclass and superclass lookup in small Python class hierarchies.
Read how The Quick Python Book, Fourth Edition explains virtual method →
Related concepts
- polymorphismconfigures · Polymorphism is a programming-language capability that lets a common interface or operation work with values of different types while allowing behavior to vary by type or implementation.
- vtableuses · A vtable is a compiler- or runtime-generated table of function or method entries used to dynamically dispatch operations for polymorphic objects or types.
- overrideaddressed by · Overriding is defining a more specific implementation that replaces inherited behavior for a type or object while preserving the operation’s interface.
- methodkind of · A method is a callable operation associated with an object or type and invoked through that association.
- visitor design patternimplemented by · The Visitor pattern separates operations on an object structure into visitor objects, allowing operations to be added without changing the structure’s element classes.
- invariantcontrasts with · An invariant is a property or condition that remains true across the valid states, operations, or specified transformations of a system or computation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


