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
You can declare a pure virtual destructor, but give it a definition. The class will be abstract, but any inheriting classes will not by default be abstract.
struct Abstract
{
virtual ~Abstract() = 0;
};
Abstract::~Abstract() {}
struct Valid: public Abstract
{
// Notice you don't need to actually overide the base
// classes pure virtual method as it has a default
};
int main()
{
// Abstract a; // This line fails to compile as Abstract is abstract
Valid v; // This compiles fine.
}