Name
default keyword — Catch-all label in switch statement
Synopsis
statement := default : statement
A switch
statement jumps to
the default
label if no case
matches the switch expression. A switch
statement can have at most one
default
label. If there is no
default
and the expression does not
match any cases, control jumps directly to the statement that follows
the switch
statement.
Example
switch(c) {
case '+': ... break;
case '-': ... break;default
:
cerr << "unknown operator: " << c << '\n';
break;
};
See Also
break
, case
, statement, switch
, Chapter 4
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.