Show: Delphi C++
Display Preferences

SSSIDC -- switch Statement Should Include the Default Case

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits

Description

SSSIDC checks that every switch statement includes the default case.

Incorrect

 switch (kind) {
   case MIN:
     return "Minimum";
   case MAX:
     return "Maximum";
   case AVG:
     return "Average";
 }

Correct

 switch (kind) {
   case MIN:
     return "Minimum";
   case MAX:
     return "Maximum";
   case AVG:
     return "Average";
   default:
     return "N/A";
 }

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance