On forcing all derived classes to implement a specific non-virtual method, part 1
Permanent link:
cppdashboard.dev/r/2026/08/on-forcing-all-derived-classes-to-implement-a-specific-non-vThis 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