On forcing all derived classes to implement a specific non-virtual method, part 2
cppdashboard.dev/r/2026/08/on-forcing-all-derived-classes-to-implement-a-specific-non-v-2This article discusses how to enforce derived classes to implement a specific non-virtual method in C++. It explores the use of deleted methods to guide developers towards correct implementation.
From the article
Last time, we observed that one way to force all derived classes to implement a specific non-virtual method is simply not to implement it in the base class and sit back and wait for the compile-time fireworks. I noted that we can do better than this, though.
The problem is that the compiler tells you what is wrong, but the details are often buried in the “supplementary error information”, and it may not be obvious how to dig it out, or maybe you dig it out but you don’t understand how to fix it.
You can steer people to the correct error by implementing the method as deleted.
Share this resource