Difference between revisions of "Cpp Coding Standards/TYPE"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
Line 9: Line 9:
  
 
[[/NoRepr|Details]]
 
[[/NoRepr|Details]]
 +
 +
==== No switch on Types <span id="NoSwitch">(NoSwitch)</span> ====
 +
Don't use switch, when the cases represent types. Prefer polymorphism.
 +
 +
[[/NoSwitch|Details]]
  
 
==== No C-Style Casts <span id="CCast">(CCast)</span> ====
 
==== No C-Style Casts <span id="CCast">(CCast)</span> ====
Line 19: Line 24:
  
 
[[/StacaPtr|Details]]
 
[[/StacaPtr|Details]]
 
==== No switch on Types <span id="NoSwitch">(NoSwitch)</span> ====
 
Don't use switch, when the cases represent types. Prefer polymorphism.
 
 
[[/NoSwitch|Details]]
 
  
 
----
 
----

Revision as of 17:25, 29 November 2006

Topic-Id: TYPE

Casts and type recognition.


Summary

Types, not Representations (NoRepr)

Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs.

Details

No switch on Types (NoSwitch)

Don't use switch, when the cases represent types. Prefer polymorphism.

Details

No C-Style Casts (CCast)

Don't use C-Style casts, but the C++ casts.

Details

Avoid static_cast on Pointers (StacaPtr)

Use dynamic_cast instead of static_cast when treating pointers polymorphically.

Details


Related Rules


Personal tools