Object-Oriented Programming

C++ Inheritance Specifiers

Michael L. Collard, Ph.D.

Department of Computer Science, The University of Akron





  • A non-const does not override a const
  • Name of a method hides (not overrides)

(Partial) Solution: override

override Notes

  • override is a specifier
  • Acts as a contextual keyword, and you are still allowed to use override as an identifier, e.g., int override = 0;
  • C# Contextual Keywords
  • C++ Keywords
  • Style Note: Can replace the declaration of virtual in derived classes
  • General Note: Instead of guessing, experiment


final Notes

  • On a class, enforces that we cannot derive from the class
  • On a method, enforces that we cannot override the method