switch statement
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
执行代码的整体参数值
Original:
Executes code according to value of an integral argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
使用一个或几个,满分许多分支的代码根据积分值需要被执行.
Original:
Used where one or several out of many branches of code need to be executed according to an integral value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 语法
switch ( expression ) {
|
|||||||||
[编辑] 解释
expression应是一个表达式,转换为一个整数值.
Original:
expression shall be an expression, convertible to an integer value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
所有constant_expressions必须是常量表达式,转换为一个整数值,这是唯一在此
switch声明Original:
All constant_expressions shall be constant expressions, convertible to an integer value, which is unique within this
switch statementThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
如果expression评估值,等于值的定义constant_expressioni,statementi(如果有的话)和所有后续语句(除了default_statement,如果存在的话)被执行。如果该值的expression不匹配任何的constant_expressions,在default_statement执行如果存在的话.
可以使用。在这种情况下,执行的Original:
If the expression evaluates to a value, equal to the value of one of the defined constant_expressioni, the statementi (if present) and all subsequent statements (except default_statement, if present) are executed. If the value of the expression does not match any of the constant_expressions, the default_statement is executed if present.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
switch声明终止. Original:
It is useful to note, that if the execution of subsequent statements is undesirable, the
break语句</div> can be used. In that case the execution of the
Original:
break statement
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
switch statement terminates. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 关键字
[编辑] 为例
| 本节是不完整的 原因: no example |