I'm a newbie in C++. As fas as I know, something like
switch(ival)
{
case 1,2,3:
/* do something */
/* other case selections */
}
is wrong. The correct way is to write:
switch(ival)
{
case 1: case 2: case 3: // in multiple lines if you prefer
/* do something */
/* other case selections */
}
That said (hoping it's correct), what happens when you compile the first? Visual Studio intellisense detects an error, but the program compiles fine.
I experimented a bit and I was betting that he would execute "do something" if ival was 1, but not if it was 2 or 3. I've setup multiple case statement like that, everyone with its own control variable to keep track of the execution, but nothing seems to happen as they all keep initialization values through the end of the program.
I'm puzzled. Anyone knows what happens behind the curtain?