In my C++ application I have an interface that looks like this:
class ICalculator
{
public:
virtual double calculateValue(double d) = 0;
};
I have implementations of this interface that look like this:
class MySpecificCalculator
{
public:
virtual double calculateValue(double d);
};
Now my colleague complains about this and tells me it's better to have the calculateValue method protected. That way, we can guarantee that the callers always pass via the interface and not via the direct implementation.
Is this a correct observation? Is it really better to make the implementation of an interface protected? Or can't we even make it private then?