Cpp Advices
Table of Contents

Inheritance

  1. Coupling: Always minimize coupling. If a class relationship can be expressed in more than one way, use the weakest relationship.
  2. Inheritance relationship: Inheritance is the one of strongest relationships. Use it when there is no equivalent weaker alternative.
  3. Make base class destructors virtual (unless you are certain that no one will ever attempt to delete a derived object through a pointer to base).
  4. When providing a function with the same name as an inherited function, be sure to bring the inherited functions into scope with a using-declaration if you don't want to hide them.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.