Difference between revisions of "Cpp Coding Standards/TYPE"
From Apache OpenOffice Wiki
m |
|||
Line 2: | Line 2: | ||
Casts and type recognition | Casts and type recognition | ||
---- | ---- | ||
− | === | + | === Summary === |
− | + | ||
==== TypesNotRepresentations ==== | ==== TypesNotRepresentations ==== | ||
Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs. | Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs. | ||
Line 19: | Line 18: | ||
=== Related Rules === | === Related Rules === | ||
* [[../CLSDESIGN#NoImplicitConversions | CLSDESIGN:NoImplicitConversions]] | * [[../CLSDESIGN#NoImplicitConversions | CLSDESIGN:NoImplicitConversions]] | ||
+ | ---- | ||
+ | === Explanations === | ||
+ | |||
---- | ---- | ||
[[Category:Coding Standards]] | [[Category:Coding Standards]] |
Revision as of 18:20, 27 November 2006
Contents
Type Safety
Casts and type recognition
Summary
TypesNotRepresentations
Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs.
NoCStyleCasts
Don't use C-Style casts, but the C++ casts.
AvoidPtrStaticCasts
Use dynamic_cast instead of static_cast when treating pointers polymorphically.
NoTypeSwitching
Don't use switch, when the cases represent types. Prefer polymorphism.