C++中有以下可能吗?开关语句继续
switch (value) {
case 0:
// code statements
break;
case 1:
case 2:
// code statements for case 1 and case 2
/**insert statement other than break here
that makes the switch statement continue
evaluating case statements rather than
exit the switch**/
case 2:
// code statements specific for case 2
break;
}
我想知道是否有办法让switch语句继续评估其余的案例,即使它遇到了匹配的案例。 (例如其他语言的continue
声明)
为什么你有'案例2'两次? – Barmar
你是什么意思*扫描*其余案件? 'switch'就像一个'goto',只有当它到达'break'时才会停止。 – andy256
@ andy256我的意思是评估。 – Dan