[Next] [Prev] [Up] [Top]

9.0 Switch Statements

Don't use case default for closed sets (enums) (R)


If a switch statement is testing an enumeration value, put an explicit case leg for each value of the enumeration. Do not use a default case. This allows the compiler to emit warnings when values are added or removed from the enumeration set.

For compilers which do not emit warnings for missing enumeration values in switch statements, insert a default case and use ASSERT or CASEFAILURE macro (see later section).


No Title
[Next] [Prev] [Up] [Top]

Generated with CERN WebMaker

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.