I have a class which is to listen to mouse events. However, I do not want to force the user to implement any specific one, but I do want to make it clear that they must inhe
Specify the constructor of the base as protected. This does mean that you cannot construct it directly, but forces inheritance. There is nothing that makes a developer inherit from that class aside from good documentation though!
Example:
struct Abstract {
protected:
Abstract() {}
};
struct Valid: public Abstract {
// No need to override anything.
};
int main() {
// Abstract a; // This line fails constructor is protected
Valid v; // This compiles fine.
}