If I have the following override of a virtual event:
void derivedClass::method(event)
{
// my stuff
baseClass::method(event); // <--
}
what does the // <— line does? What does it call? I don’t think it calls the base class’ method because it’s virtual (so no body)
As you are suggesting, it calls the base class’ method. The fact that it is virtual it only means it can be overridden and still access to the derived class’ method from a pointer/reference to the base class.
The reason to do that can be easily seen with an example:
It might be the case that you do not want to do the generic stuff for
Derivedclass. Then you would just remove the call toBase::foo().Here you have a good reference on virtual methods.