C++ abstract class without pure virtual functions?

You could declare, and implement, a pure virtual destructor:

class ShapeF
{
public:
    virtual ~ShapeF() = 0;
    ...
};

ShapeF::~ShapeF() {}

It’s a tiny step from what you already have, and will prevent ShapeF from being instantiated directly. The derived classes won’t need to change.

Leave a Comment