Say I have base and derived classes
class MyBaseClass
{
public:
virtual void MustBeOverRidden()
{
DoSomething();
}
};
class MyDerivedClass : public MyBaseClass
{
public:
void MustBeOverRidden()
{
MyBaseClass::DoSomething();
DoSomethingElse();
}
};
if BaseClass was abstract, I could declare
virtual void MustBeOverRidden() = 0;
however in this case the base class functionality will typically be called as part of the derived functionality. Is there any way to force all derived classes to override the base class function in this case? Alternatively, can I provide an implementation for a pure virtual function?
Edit: Implementation for a pure virtual function does not work as I need to be able to instantiate my base class, which results in error C2259: 'MyBaseClass' : cannot instantiate abstract class