A member function can be declared abstract ( = 0 ) only if it is virtual. Add the virtual to the function declaration in the base class (in class A ).
Before C ++ 11, it was also good practice to repeat virtual in declaring a derived member function of a class, although this is not technically necessary there (since the rule is "once virtual, always virtual").
In C ++ 11, the override keyword is introduced, which can be used when redefining a virtual member function to protect the code from future changes (i.e., if the base function changes its signature, the derived code cannot be compiled instead of becoming silently silent). Enabling or disabling virtual if there is an override depends on the personal taste / coding standards of the project. I consider this unnecessary and omit it, but this is only my personal preference.
Angew
source share