I\'ve always wondered this - why can\'t you declare variables after a case label in a switch statement? In C++ you can declare variables pretty much anywhere (and declaring
My favorite evil switch trick is to use an if(0) to skip over an unwanted case label.
switch(val) { case 0: // Do something if (0) { case 1: // Do something else } case 2: // Do something in all cases }
But very evil.