This is more of a question, but why is this not allowed?
You would get somthing like:Code:switch ( choice )
{
case 1:
int x = 5;
break;
}
In some cases, decalring a new variable within a case structure like the above would erradicate having to delcare the value at the start of the program.Quote:
main.cpp(85) : error C2360: initialization of 'x' is skipped by 'case' label
Is there any reason why the language does not allow it?