Difference between revisions of "Cpp Coding Standards/TYPE"
From Apache OpenOffice Wiki
m |
m |
||
Line 1: | Line 1: | ||
− | Topic-Id: TYPE | + | Topic-Id: '''TYPE''' |
Casts and type recognition. | Casts and type recognition. |
Revision as of 17:25, 29 November 2006
Topic-Id: TYPE
Casts and type recognition.
Contents
Summary
Types, not Representations (NoRepr)
Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs.
No switch on Types (NoSwitch)
Don't use switch, when the cases represent types. Prefer polymorphism.
No C-Style Casts (CCast)
Don't use C-Style casts, but the C++ casts.
Avoid static_cast on Pointers (StacaPtr)
Use dynamic_cast instead of static_cast when treating pointers polymorphically.
Related Rules
- CLSDESIGN:NoConv - No Implicit Conversions