Article

On forcing all derived classes to implement a specific non-virtual method, part 1

The Old New Thing ·The Old New Thing ·Published 2026-08-27 ·5 min read

This article discusses how to ensure that derived classes implement specific methods in C++ by using a base class. It provides examples using IValueConverter and OneWayConverter to illustrate the concept.

From the article

You may have a base class that implements only partial functionality and relies on the derived class to do the rest. How do you make sure that the derived class does the rest?

For concreteness, let’s say that we are implementing IValueConverter , which has two methods:

Suppose you want to write a base class called OneWayConverter . Its implementation fails the ConvertBack() call, and you want to force the derived class to implement the forward conversion.


Share this resource


Discovered 2026-08-28 Source The Old New Thing Archive 2026-08 →