Item 12: Declare Overriding Functions override

Because it is easy to miss the 6 conditions for overriding to occur.

  • The base class function must be virtual
  • The function name must be identical (except for destructor)
  • The parameter types must be identical
  • The constness must be identical
  • The return type and exception specifications must be compatible (not necessarily identical)
  • (C++11) The function’s reference qualifiers must be identical
Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.