Help with my code please

Write your question here.
I am having issues with my program in which it doesn't actually change the value of my variables in my classes so that I can then use in my battlesequence. This snippet is the function where i'd like to use them. I'm pretty tying to have it kill the loop once the enemy is dead by checking to see if the enemy is dead. This isn't finished it just basic and will probably need a lot more work.. I don't wanna put the rest of the code as it'll be a huge chunk soo yeah. Unless I have to then i might.
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
 void enemyHealth(float damage)
{
	enemy1Hp = enemy1Hp - damage;

	if (enemy1Hp > 0)
	{
		cout << "The enemy now has " << enemy1Hp << endl;
	}
	else
	{
		cout << "You have slain the enemy " << endl;
		enemies typeE;
		typeE.setBandit(1);
	}
		 
}

//This is for the battle moments with the enemys.
int battleSequence(void)
{
	while (true)
	{	//srand(time(NULL));
		int playerChoice;
		int gameAttack = rand() % 4 + 1;
		float damageC;
		int taunt = rand() % 2 + 1;
		int ragey = rand() % 2 + 1;
		bool wuuthrad;
		string rage;
		string twant;

		enemies typeE;
		cout << typeE.getOrc();
		if (typeE.getOrc() <= 0){
			break;
		}
//This is my class that i'm using to change and set values and stuff...

#pragma once
class enemies {

public:
	enemies();
	~enemies();
	void setBandit(float BanditN) {
		Bandit = BanditN;
	}
	float getBandit() {
		return Bandit;
	}


	void setMage(float MageN) {
		Mage = MageN;
	}
	float getMage() {
		return Mage;
	}


	void setOrc(float OrcN) {
		Orc = OrcN;
	}
	float getOrc() {
		return Orc;
	}


	void setDarkMage(float DarkMageN) {
		darkMage = DarkMageN;
	}
	float getDarkMage() {
		return darkMage;
	}

	void setKingRagnok(float KingRagnokN) {
		KingRagnok = KingRagnokN;
	}
	int getKingRagnokN() {
		return KingRagnok;
	}
	/* Using the object in private in public, thus keeping them secure and being
	able to keep them secure by only using them in public to manipulate them for my main*/
private:
	float Bandit = 10;
	float Mage = 15;
	float Orc = 20;
	float darkMage = 18;
	float KingRagnok = 30;
};




Sorry if I suck :/...
Last edited on
I think you need to use call by reference functions in your program so that you can actually change your vallues
Last edited on
Yes that makes sense now that I think about it. Thanks for the advice/info I'll try to get that done.
Welcome :D
if your still here could you please help me man? I've been trying to use pointers and pass by reference but i've been having a load of problems.. I'm a noob so could you possibly help me with my code in where I can pass by reference?
closed account (48T7M4Gy)
http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.