You can make the destructor pure virtual, and have that be your "dummy function". i.e.
class Bad_Date
{
private:
const char* _my_msg;
public:
const char* msg() const { return _my_msg; }
virtual ~Bad_Date() = 0;
};
Making the destructor virtual is a good idea anyway for any class you intend to use polymorphicaly, to ensure that subclass instances get cleaned up appropriately. If you need Bad_Date to do some work in the destructor though, you can't make the destructor pure virtual of course. Making Bad_Date
's constructor(s) protected is another viable technique. This will ensure that a Bad_Date
can only be constructed by a subclass of Bad_Date
. Unfortunately this won't prevent someone from creating a Bad_Date
subclass just to act as factory for Bad_Date
s.
Beyond that there are compiler specifc extensions for creating abstract base classes, e.g. MSVC has __interface
and gcc has used to have signature
.