In delegate pattern is it good to make the destuctor virtual ?
class MyClass
{
...
};
class MyClassDelegate
{
...
};
On one hand class MyClassDelegate is an interface and supposed to be inherited from, but on the other hand it’s not supposed to delete the subclass via the MyClassDelegate pointer
What do you think ?
You could consider making it protected non-virtual – then you’re actually enforcing and documenting the fact that you can’t delete an object using that kind of pointer. Some more discussion can be found here