default keyword

   
default keyword Catch-all label in switch statement

  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

   


C++ in a Nutshell
C++ in a Nutshell
ISBN: 059600298X
EAN: 2147483647
Year: 2005
Pages: 270
Authors: Ray Lischner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net