switch stament instead of ifand else?

okey, i have the start of my first text based game. But as you can se it's connected to my header which is connected to

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
 
  
/*
	Level 1
*/

#include <iostream>
#include <string>
#include <vector>
#include "Header.h"

PlayerOne(Inventory);// does not work but i want to acces the class inventory from PlayerOne
char userInput[50];

levelOne::levelOne()
{
	while (true)
	{
		std::cout << "You're in a dark room\n>>";
		std::cin >> userInput;
		std::cin.ignore();


		if (!strcmp(userInput, "look"))
		{
			std::cout << "you can see a barrel and a door" << std::endl;

			Inventory.push_back("apple"); //example to add apple into Inventory
			std::cin.clear();
			std::cin.ignore();

 		}


		if (!strcmp(userInput, "quit"))
		{
			system("cls");
			std::cout << "Quitting" << std::endl;
			std::cin.ignore();
			break;
		}

	}

}
----------------------------------------------------------playerOne.cpp

#include <iostream>
#include <string>
#include <vector>
#include "Header.h"


PlayerOne::PlayerOne
{
	class player
	{
	public:
		std::vector<int> pos;
	};
	
	class Inventory
	{
	public:
		std::vector<std::string> inv; //this is the vector i want to put all my items in.
	};

	class Life
	{
	public:
		bool life = true;
	};
}

---------------------------------------------------Header file(which everything is connected too)

#ifndef HEADER_H
#define HEADER_H



class PlayerOne
{
public:
	PlayerOne();
};

class levelOne
{
public:
	levelOne();
};


#endif //HEADER_H


Thanks for all the help i can get.
Last edited on
Topic archived. No new replies allowed.