Cpp Coding Standards/VIRTUAL/LSP

From Apache OpenOffice Wiki
< Cpp Coding Standards‎ | VIRTUAL
Revision as of 17:15, 14 December 2009 by B michaelsen (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Liskov Substitution Principle (LSP)

See http://en.wikipedia.org/wiki/Liskov_substitution_principle.

This statement can be put into different wordings to view different aspects:

  • Everything you can do with a base class, you need to be able to do with any of its derived classes.
  • A derived class must not require more and must not promise less than its base class.
  • Overridden versions of virtual functions must not have stronger preconditions or weaker postconditions than the version of the base class.
  • The client of a base class must never need to know, which derived class it is using really.
Personal tools