title: C++ Switch Statement Case Error
body: <p>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.</p>
  
  <pre><code>int main(void)
  {
      // add weapons to array
      Weapon *weaponList[12];
      // Rusty Sword
      weaponList[0] = new Weapon(0,0,0);
      weaponList[0]-&gt;SetAll(0,2,3);
      // Bronze Sword
      weaponList[1] = new Weapon(0,0,0);
      weaponList[1]-&gt;SetAll(1,5,10);
      // Bronze Battle Axe
      weaponList[2] = new Weapon(0,0,0);
      weaponList[2]-&gt;SetAll(2,15,30);
      // Iron Sword
      weaponList[3] = new Weapon(0,0,0);
      weaponList[3]-&gt;SetAll(3,25,70);
  
      // add armor to array
      Armor *armorList[12];
      // Worn Platemail
      armorList[0] = new Armor(0,0,0);
      armorList[0]-&gt;SetAll(0,2,3);
      // Bronze Chainmail
      armorList[1] = new Armor(0,0,0);
      armorList[1]-&gt;SetAll(1,5,8);
      // Bronze Platemail
      armorList[2] = new Armor(0,0,0);
      armorList[2]-&gt;SetAll(2,7,20);
      // Iron Chainmail
      armorList[3] = new Armor(0,0,0);
      armorList[3]-&gt;SetAll(3,15,60);
  
          while(gamestate != 8)
          {
              switch(gamestate)
              {
                  case 0:
                  cout &lt;&lt; " /|    Welcome!\n"
                       &lt;&lt; " ||    \n"
                       &lt;&lt; " ||    \n"
                       &lt;&lt; " ||    \n"
                       &lt;&lt; "_||_   \n"
                       &lt;&lt; " 88    \n"
                       &lt;&lt; " 88    Name: ";
                  cin  &gt;&gt; heroName;
                  gamestate = GAME_STATE_MENU;
                  break;
  
              case 1:
                  cout &lt;&lt; "\n"
                       &lt;&lt; "'/stats' will show you your stats\n"
                       &lt;&lt; "'/shop' will let you visit the weapon shop\n"
                       &lt;&lt; "secret commands: /setweapon #   /setarmor #   /setheroexp #\n"
                       &lt;&lt; "\n";
  
                  cout &lt;&lt; "Command: ";
                  cin  &gt;&gt; command;
  
                  if (strcmp(command, "/stats") == 0)
                  {
                      gamestate = 2;
                      break;
                  }
  
                  else if (strcmp(command, "/shop") == 0)
                  {
                      gamestate = 3;
                      break;
                  }
  
                  else if (strcmp(command, "/fight") == 0)
                  {
                      gamestate = 4;
                      break;
                  }
  
                  else if (strcmp(command, "/setweapon") == 0)
                  {
                      cin &gt;&gt; testNum;
                      heroWeapon = testNum;
                      break;
                  }
  
                  else if (strcmp(command, "/setarmor") == 0)
                  {
                      cin &gt;&gt; testNum;
                      heroArmor = testNum;
                      break;
                  }
  
                  else if (strcmp(command, "/setheroexp") == 0)
                  {
                      cin &gt;&gt; testNum;
                      heroExp = testNum;
                      LevelUp();
                      break;
                  }
  
                  else if (strcmp(command, "/exit") == 0)
                  {
                      gamestate = 8;
                      break;
                  }
  
                  else
                  {
                      cout &lt;&lt; "Please enter a valid command.\n";
                      gamestate = 2;
                      break;
                  }
  
              case 2:
                  Weapon *wCurrent = weaponList[heroWeapon];
                  Armor *aCurrent = armorList[heroArmor];
                  heroWeaponPower = wCurrent-&gt;GetWeaponAttack();
                  heroArmorDefense = aCurrent-&gt;GetArmorDefense();
                  heroPowerDefault = ((heroLevel - 1) * 10) + 10;
                  heroPower = heroPowerDefault + (heroStrength * 2) + heroWeaponPower;
                  heroDefenseDefault = ((heroLevel - 1) * 2) + 5;
                  heroDefense = heroDefenseDefault + (heroAgility / 5) + heroArmorDefense;
                  heroHealthDefault = (heroLevel * 5) + 20;
                  heroHealth = heroHealthDefault + (heroStamina * 10);
                  cout &lt;&lt; "\nS T A T S\nName: " 
                       &lt;&lt; heroName 
                       &lt;&lt; "\nLevel: "
                       &lt;&lt; heroLevel
                       &lt;&lt; "\nExp: "
                       &lt;&lt; heroExp &lt;&lt; "/" &lt;&lt; expForLevel[heroLevel]
                       &lt;&lt; "\nGold: "
                       &lt;&lt; heroGold
                       &lt;&lt; "\nHealth: "
                       &lt;&lt; heroHealth
                       &lt;&lt; "\nPower: "
                       &lt;&lt; heroPower
                       &lt;&lt; "\nDefense: "
                       &lt;&lt; heroDefense
                       &lt;&lt; "\nWeapon: "
                       &lt;&lt; weaponNameList[heroWeapon]
                       &lt;&lt; "\nArmor: "
                       &lt;&lt; armorNameList[heroArmor]
                       &lt;&lt; "\n\n";
                  system("PAUSE");
                  gamestate = 2;
                  break;
  
              case 3:
                  break;
              }
          }
  
          return 0;
      }
  </code></pre>