Input into private class variable in class function

Hello everyone! I am trouble with this program. I made a class for my SFML game that manages everything. However, when I am trying to input the character name and gender, it doesn't register.

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <string>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

static class GameEngine
{
private:

	class Character
	{
	private:
		int gender; //1 is male and 2 is female and 3 is other/none
		string name;
		float health;
		float maxHealth;
		float magic;
		float maxMagic;
		float attack;
		float defense;

	public:
		void NameAndGender(string Inname, int Ingender)
		{
			name = Inname;
			gender = Ingender;
		}
		int getGender()
		{
			return gender;
		}
		int LevelPosition = 21; //259
		sf::Sprite sprite;
		sf::Texture texture;
		bool AskAttributes_MainMenu()
		{
			cout << "Define character name and gender with a space in the middle. \n1 for male, 2 for female, 3 for other or none ";
			scanf_s("%s %d", name, gender);
			//cout << "Is your character male or female? 1 for male, 2 for female, 3 for other or none ";
			//cin >> gender;
			//NameAndGender(InName, InGender);
			system("cls");
			return true;
		}
		void InitializeCharacter()
		{
			switch (gender)
			{
				case 1:
					if (!texture.loadFromFile("Textures/RPG_Hero.png"))
					{
						cout << "Error loading RPG_Hero.png";
					}
					sprite.setTexture(texture);
					sprite.setPosition(32, 32); //(576,352)
					break;
				case 2:
					if (!texture.loadFromFile("Textures/RPG_Hero_Female.png"))
					{
						cout << "Error loading RPG_Hero.png";
					}
					sprite.setTexture(texture);
					sprite.setPosition(32, 32); //(576,352)
					break;
				case 3:
					if (!texture.loadFromFile("Textures/RPG_Hero_Female.png"))
					{
						cout << "Error loading RPG_Hero.png";
					}
					sprite.setTexture(texture);
					sprite.setPosition(32, 32); //(576,352)
					break;
				default:
					cout << "Gender error!\n"; //always gives this error
					cout << gender;
					if (!texture.loadFromFile("Textures/RPG_Hero.png"))
					{
						cout << "Error loading RPG_Hero.png";
					}
					sprite.setTexture(texture);
					sprite.setPosition(32, 32); //(576,352)
					break;
			}
		}
	};


public:
	int CurrentLevel[280];
	sf::RenderWindow RPGWindow;
	enum State { StartUp, Menu, Paused, InLevel, InBattle, InHubWorld };
	void update();
	void draw();
	void run();
	TileMap map;
	State GameState;
	Character Hero;
	void InitializeEngine();
}RPGEngine;


Some things not related to the program have been cut out to make it shorter. I have tried many things to get it to work including the usual cin, printf, and getline but it doesn't work. Any help on this?
Topic archived. No new replies allowed.