if else statement using strings?

I'm trying to make

string gender;
cin >> gender;
If ( gender == boy ) but I can't seem to get it to work.
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
34
35
36
  #include <iostream>
#include <string>

using namespace std;

int main ( ) 
	{
		string name;
		string gender;
		string boy;
		string girl;
		
		cout << "Hello, welcome to the World.\n";
		
		cout << "What's your name?\n";
		
		cin >> name;
		
		cout << "Nice to meet you " << name << endl;
		
		cout << "Are you a boy or girl?\n";
		
		cin >> gender;
		
		
		
		if ( gender == boy ) 
			{
				cout << "Kind of small for a boy, hope you learn fast.\n";
			}
				else 
					{ cout << "A girl? Don't get many girls around these parts.\n";
					}
		
		return 0; 
	}
Nevermind... figured it out myself...

 
If ( gender == "boy" )


Forgot quotes on boy.

Last edited on
DonĀ“t forget to close the case as solved ;) Have a nice day.
Topic archived. No new replies allowed.