value assignment with cin

I'm having trouble with this section of my code.

case 2:
cout<<"You drive the knife deep into the zombie's temple and watch it fall to"<<endl;
cout<<"the ground! Do you wish to retrieve your knife from the zombie's skull?"<<endl;

if (knifechoice==yes)
cout<<"You retrieve your knife."<<endl;

else if (knifechoice==no)
cout<<"That's pretty gross, I'll just leave it there."<<endl;

cout<<"Yes or no please."<<endl;
THe rest of the program works, but it says in this section that the answers (yes and no) are undefined. Am I using cin incorrectly, or are yes and no some kind of c++ function that I just don't know about?
If knifechoice is a string then you need if (knifechoice=="yes") otherwise the compiler thinks yes is a variable.


EDIT - Pleas always use code tags - select your code then press the <> button on the right.
Last edited on
Topic archived. No new replies allowed.