Cpp Coding Standards/CLSDESIGN/Inherit

From Apache OpenOffice Wiki
< Cpp Coding Standards‎ | CLSDESIGN
Revision as of 23:06, 19 July 2007 by Kirk (Talk | contribs)

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

Avoid inheritance, because it induces the second highest coupling possible in c++ (second only to friendship). Instead, prefer composition by default.

If you employ public inheritance, use it to be reused and not to reuse another implementation. That is, inherit publicly from a baseclass, to allow client code to use your class instead of the base class. Make sure you don't violate the LSP doing so.

Personal tools