Y
yndygo
Alright then - I know it's got to be out there somewhere, but I can't
find it...
I'm looking at a piece of code and there's some debate as to what the
behavior will be.
Given a switch/case where there is a function call after the switch
but *before* the first case statement, will the function call never
get reached? or always?
To whit:
switch (value) {
//this is where weird function call is... comment says run every
time
randomfunction(x,y);
case 1:
cout << "foo!\n";
break;
case 2:
cout << "fah!\n";
break;
default:
cout << "foofah!\n";
break;
}
So what happens? does randomfuntion() get called every time? never?
The code has been successfully compiled... but no idea if there was a
warning or not.
Anyone?
find it...
I'm looking at a piece of code and there's some debate as to what the
behavior will be.
Given a switch/case where there is a function call after the switch
but *before* the first case statement, will the function call never
get reached? or always?
To whit:
switch (value) {
//this is where weird function call is... comment says run every
time
randomfunction(x,y);
case 1:
cout << "foo!\n";
break;
case 2:
cout << "fah!\n";
break;
default:
cout << "foofah!\n";
break;
}
So what happens? does randomfuntion() get called every time? never?
The code has been successfully compiled... but no idea if there was a
warning or not.
Anyone?