this is my first post. Im an amateur programmer who just recently learned Classes and Inheritance. So I thought I'd practice what I've learned by attempting to make a text based RPG. However, im having a problem with my Switch statement in this function:
...
void Character::classSelect()
{
cout << "---- Choose the Class of your Hero ----\n";
cout << "---- (1) -- Warrior -------------------\n";
cout << "---- (2) -- Mage ----------------------\n";
cout << "---- (3) -- Battlemage ----------------\n";
cout << "---------------------------------------\n";
int c;
cin >> c;
switch (c)
{
case 1: m_class = "Warrior", hp = 35, physDmg = 5, magicDmg = 1;
case 2: m_class = "Mage", hp = 20, physDmg = 1, magicDmg = 10;
case 3: m_class = "Battlemage", hp = 25, physDmg = 7, magicDmg = 7;
default: m_class = "Warrior", hp = 35, physDmg = 5, magicDmg = 1;
cout << "You chose : " << m_class << endl;
}
}
...
void Character::print()
{
cout << getCharClass() << " (HP:" << getHp() << "/DAMAGE-PHYICAL:" <<
getPhysDmg() << "/DAMAGE-MAGICAL:" << getMagicDmg() << ")\n";
}
...
int main()
{
Character player;
player.classSelect();
player.print();
return 0;
}
It seems to print the default case every time, no matter what I input with 'cin'. For example, If I enter 2 it still prints "Warrior (HP .....". Any help would be appereciated.