Enumeration in switch statements

suggest change

A common use for enumerators is for switch statements and so they commonly appear in state machines. In fact a useful feature of switch statements with enumerations is that if no default statement is included for the switch, and not all values of the enum have been utilized, the compiler will issue a warning.

enum State {


switch(myState) {
    case start:
    case middle:
} // warning: enumeration value 'end' not handled in switch [-Wswitch]

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents