A
alacrite
If I have code like this:
int main()
{
a=1;
b=2;
x=0;
switch(a)
{
case a:
x=50;
a=b;
break;
case b:
cout<<x; // x=0
break;
}
}
Why will x=0 and not 50 when it is printed in case b? It has scope why
does each case cause it to go back to 0? Is there a way to make the
changes that happen to it in 'a' still be there in 'b'?
thanks,
-Jake
int main()
{
a=1;
b=2;
x=0;
switch(a)
{
case a:
x=50;
a=b;
break;
case b:
cout<<x; // x=0
break;
}
}
Why will x=0 and not 50 when it is printed in case b? It has scope why
does each case cause it to go back to 0? Is there a way to make the
changes that happen to it in 'a' still be there in 'b'?
thanks,
-Jake