I need to setup a class inheritance structure, in which the abstract base class only holds member variables (but no member methods). The member methods will be defined by the derived classes. Hence, what I need is this post: Making a class abstract without any pure virtual methods
From the top 2 answers there, I realised there are 2 ways of achieving it:
- Make the destructor pure virtual.
- Make the constructor protected.
I am curious to know the difference between the two approaches. Are there scenarios where one should be preferred over the other (or maybe some special situations where one would work but not the other)? I thought about it and could not think of anything.
I searched through the answers on some posts here ( Is there a use for making a protected destructor virtual? , C++: Protected Class Constructor , Should an abstract class' destructor be pure virtual? ) to try to put something together, but I could not come to a conclusion.