Suppose I have a switch statement like in the following pseudo-code (sorry about the formatting - the lack of attaching inline code in this forum is atrocious):
switch(foo)
{
case 1:
int bar = 0;
break;
case 2:
char bar = 'a';
break;
}
Will I get a 'variable redefinition' warning when compiling this (since 'bar' is both an int and a char)? Or is the scope of a local variable constrained to a case statement?
In other words, does a case constitute a 'block' of code?
switch(foo)
{
case 1:
int bar = 0;
break;
case 2:
char bar = 'a';
break;
}
Will I get a 'variable redefinition' warning when compiling this (since 'bar' is both an int and a char)? Or is the scope of a local variable constrained to a case statement?
In other words, does a case constitute a 'block' of code?