关于开关的问题 [英] Question on switch
问题描述
是否有可能在这种情况下经历多个案件?怎么样?
开关(foo)
{
案例1或2:
dosomething( );打破; //如果foo为1或2,则为dosothing
案例3:
dosomethingelse();打破; // dosomethingelse如果foo是3
}
-
Ian Tuomi
Jyv? skyl ?,芬兰
非常有趣的scotty,现在让我的衣服光亮。
GCS d-s +:a-- - C ++> $ L +> +++ $ E- W + N +!o> + w ---
!O-!M-t +!5!X R + tv-b ++ DI +!DG e-> +++ h!
注意:从地址中删除NOSPAM
Is it possible to go through multiple cases in one case like this? how?
switch(foo)
{
case 1 or 2:
dosomething(); break; //dosomething if foo is either 1 or 2
case 3:
dosomethingelse(); break; // dosomethingelse if foo is 3
}
--
Ian Tuomi
Jyv?skyl?, Finland
"Very funny scotty, now beam down my clothes."
GCS d- s+: a--- C++>$ L+>+++$ E- W+ N+ !o>+ w---
!O- !M- t+ !5 !X R+ tv- b++ DI+ !D G e->+++ h!
NOTE: Remove NOSPAM from address
推荐答案
L +> +++
L+>+++
E-W + N +!o> + w ---
!O-!M-t + !5!X R + tv-b ++ DI +!DG e-> +++ h!
注意:从地址中删除NOSPAM
E- W+ N+ !o>+ w---
!O- !M- t+ !5 !X R+ tv- b++ DI+ !D G e->+++ h!
NOTE: Remove NOSPAM from address
Andreas Kahari写道:
Andreas Kahari wrote:
是:
switch(foo){
案例1:/ * FALLTROUGH / *
案例2:
吧();
休息;
Yes:
switch (foo) {
case 1: /* FALLTROUGH /*
case 2:
bar();
break;
我现在很困惑。
看看那段代码看起来好像没有做任何事情
和访问bar()它需要foo = 2
我缺少什么?
-
Ian Tuomi
Jyv?skyl ?,芬兰
非常有趣的scotty,现在让我的衣服光亮。
>
GCS d- s +:a --- C ++>
I''m alittle confused now.
Looking at that piece of code it looks like in case 1 nothing is done
and to access bar() it would require that foo = 2
What am I missing?
--
Ian Tuomi
Jyv?skyl?, Finland
"Very funny scotty, now beam down my clothes."
GCS d- s+: a--- C++>
这篇关于关于开关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!