Does initialization statement can't be used in the case of switch statement ? Here is my code
#include <iostream>
int nosenseFun(int choice){
switch(choice){
case 1:
int temp = 1;
return temp;
case 2:
break;
default:
return 0;
}
return 2;
}
int main(){
return 0;
}
And when I compile it using g++, I got error message like that
testSwitch.cpp:14:14: error: jump to case label [-fpermissive]
testSwitch.cpp:12:17: error: crosses initialization of ‘int temp’
Does initialization statement can't be used in the case of switch statement ?