So, for my homework I need to create a linked list of 20 random "monsters" using a templated linked list. This will be created in the CTOR of the "Arena" class.
Visual studio is giving me an error when trying to compile when entering the switch/case for which monster to create at random. It is happening for every case:
error C2360: initialization of 'monsterTypeTroll' is skipped by 'case' label
In the Arena header file, I have this ENUM:
Code:
enum MonsterType
{
troll = 1,
ogre,
spectre,
dragon,
giantScorpion,
human,
wyrm,//human/dragon
spectralOgre,//ogre/specter
giantSpider,
wife//just for fun, wifey laughed :)
};
In the associated .cpp, in the CTOR, I have this:
Code:
//local variable declarations
Random rdm;
MonsterType type;
//create 20 monster list here
for( int i = 0; i < MONSTER_LIST_LENGTH; i++ )
{
type = static_cast<MonsterType>(rdm.GetRandNumb( 1, 10 ));
//why is it skipping each case statement?
switch( type )
{
case troll:
Troll * monsterTypeTroll = new Troll;
m_monsterList.PushBack( monsterTypeTroll );
break;
case ogre:
Ogre * monsterTypeOgre = new Ogre;
m_monsterList.PushBack( monsterTypeOgre );
break;
case spectre:
Spectre * monsterTypeSpectre = new Spectre;
m_monsterList.PushBack( monsterTypeSpectre );
break;
case dragon:
Dragon * monsterTypeDragon = new Dragon;
m_monsterList.PushBack( monsterTypeDragon );
break;
case giantScorpion:
GiantScorpion * monsterTypeScorpion = new GiantScorpion;
m_monsterList.PushBack( monsterTypeScorpion );
break;
case human:
Human * monsterTypeHuman = new Human;
m_monsterList.PushBack( monsterTypeHuman );
break;
case wyrm:
Wyrm * monsterTypeWyrm = new Wyrm;
m_monsterList.PushBack( monsterTypeWyrm );
break;
case spectralOgre:
SpectralOgre * monsterTypeSpectralOgre = new SpectralOgre;
m_monsterList.PushBack( monsterTypeSpectralOgre );
break;
case giantSpider:
GiantSpider * monsterTypeSpider = new GiantSpider;
m_monsterList.PushBack( monsterTypeSpider );
break;
case wife:
Wife * monsterTypeWife = new Wife;
m_monsterList.PushBack( monsterTypeWife );
break;
}
}
I've tried using a simple int like "1" instead of "troll" or whatever. Not sure why this is happening. I thought I knew how this worked =/