I've already read this " Why can't variables be declared in a switch statement? ".
However, I still can't understand why does this work:
switch(n){
case VAL:
int a;
...
break;
case OTHER_VAL:
a = 12
...
break;
}
suppose to this:
switch(n){
case VAL:
int a = 12;
...
break;
case OTHER_VAL:
...
break;
}
I understand that that initialization part is bypassed, at the label val
, so why does the declaration part isn't?.