liveBook · Manning

Pure virtual member function

A pure virtual member function is a virtual function declared as requiring derived classes to provide an override, typically making its declaring class abstract.

How 2 Manning books explain it

100 C++ Mistakes and How to Avoid Them

A pure virtual function is a C++ virtual member function declared without a required implementation in the declaring class and intended to be overridden by derived classes.

How it is used
Uses pure virtual functions to express shared behavior without forcing unrelated classes into an implementation hierarchy.
How deep it goes
Defines the interface pattern and shows implementations, but stops short of detailed object-model or language-runtime internals.
Examples
Uses Square, Horse, Moveable, dynamic_cast, and a collection of Moveable pointers to contrast misleading and meaningful relationships.
What you can do after
Apply it via an interface-like base when classes share meaningful behavior, while avoiding inheritance based only on matching method names.

Read how 100 C++ Mistakes and How to Avoid Them explains pure virtual member function →

Learn C++ by Example

A pure virtual function is a virtual member function declared without an implementation requirement in its declaring class, making that class abstract unless overridden.

How it is used
Defines a polymorphic interface for blob types that must provide stepping and step-count behavior.
How deep it goes
Explains declaration, abstractness, overriding, and v-table dispatch, while deferring broader special-member-function details.
Examples
Uses a Blob race, a StepperBlob implementation, pointer-based dispatch, and an assertion checking two-step movement.
What you can do after
Build it from scratch as an abstract C++ interface and implement checked concrete subclasses.

Read how Learn C++ by Example explains pure virtual member function →

Related concepts

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.