Consider a class that is supposed to offer some (polymorphic) methods such as arithmetic or bitwise operators for all its subclasses. These operations should NOT be modifiable by the derived classes to ensure correct execution. However, at the same time I would like to have the evaluation of subclasses (with the function isError() in my example) be individually defined:
class Mom
{
public:
virtual bool operator && (const Mom&) const final
{
return this->isError() && p_rOther.isError();
}
private:
virtual bool isError() = 0;
};
This does not seem to be allowed given the current standard, as the "pure virtuality" implies the necessity for subclasses to implement all virtual functions of the baseclass, whereas the "final" keyword contradicts this paradigm.
Any suggestions or ideas how to handle this contradiction?