I need help with my program

hello i am very new to c++ and i decided for practice that i would make a simple text dungeon crawler game however i have run into a problem when i type in the class i want it always replys with "Moron type one of the real ones" this should only happen if someone types in a word that isnt one of the choices.I pressume this is because the varibles for archer solider and mage dont have any values but how can i fix this?

sorry if what i am sayin makes no sense i am very new to this and do not know the jargon but it would be very appreciated if you guys/gals could help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>

using namespace std;

int main()
{
    string archer;
    string solider;
    string mage;
    string yourname;
    string class123;
    cout << "Wellcome to Dungeon crawler! Please enter your name:" << endl;
    cin>> yourname;
    cin.ignore();
    cout<< "Hello! "<< yourname << " please choose your class:\n Archer \n Solider \n Mage" << endl;
    cin>> class123;
    cin.ignore();
    if (class123 == archer){
    cout<< "You are now an archer!";
    }
    else if (class123 == solider){
    cout<< "you are now a solider!";
    }
    else if (class123 == mage){
    cout<< "You are now a mage";
    }
    else {
    cout<< "Moron type one of the real ones";
    cin>> class123;
    cin.ignore();
    }
    return 0;
}
Last edited on
It's because your class names are uninitialized variables.
Declare them like this:
1
2
3
string archer("archer");
string solider("solider");
string mage("mage");
Topic archived. No new replies allowed.