C++ Switch Statement Case Error
- by Metal_Drummer
I'm programming a simple text-based RPG using a switch statement for a game loop. The program works fine until I attempt to add another case statement, at which point it gives me the following three errors: "jump to case label" (error occurs at the line of the newly added case), and two "crosses initialization of 'ClassName *objectName'"(errors occur when the new objects are created in case 2). I'll paste the important code, if anyone needs more, please let me know.
int main(void)
{
//initiate first object array and add some objects
//initiate second object array and add some objects
while(gamestate != 8)
{
switch(gamestate)
{
case 0:
//do some stuff
break;
case 1:
//do some stuff
break;
case 2:
//declare new objects of the two...
//...classes I have (ClassName *objectName)
//do some stuff
break;
case 3: //this is the case I am trying to add
//do nothing
break;
}
}
return 0;
}