Article 12 of "Effective Modern C++" study notes: add an override statement after the function intended to be rewritten

The role of the override statement is very simple, that is, when you rewrite a member function inherited from the parent class for a subclass, if the rewriting fails for various reasons (there are many reasons for failure, such as incorrect parameter types, missing function modifiers Etc.), will give you a clear prompt when compiling.

Shorthand

  • Add an override statement after the function intended to be rewritten
  • Member function lvalue reference modifiers (&) and rvalue reference modifiers (&&) can distinguish between lvalue objects and rvalue objects (*this).

Guess you like

Origin blog.csdn.net/Chiang2018/article/details/114240412