Difference between revisions of "Cpp Coding Standards/VIRTUAL/LSP"
From Apache OpenOffice Wiki
B michaelsen (Talk | contribs) |
|||
Line 9: | Line 9: | ||
* Overridden versions of virtual functions must not have stronger preconditions or weaker postconditions than the version of the 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. | * The client of a base class must never need to know, which derived class it is using really. | ||
+ | [[Category:Coding Standards]] |
Latest revision as of 17:15, 14 December 2009
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.