This question already has an answer here:
These are some concern I have since when I understand how to use and what to use virtual functions for.
First, online, I've seen many styles for declaring virtual functions. While virtual is always (obviously) written in the base class's virtual function declaration, the derived class's declaration is sometimes declared with virtual, sometimes with override, sometimes with both, sometimes with neither. What is the correct style?
Second, if I have a virtual function in the base class, but in one of the derived classes I don't want to make that function usable, how do I do it?
Third, do I have to put virtual in the function definition (in the .cpp file)?
Aucun commentaire:
Enregistrer un commentaire