Trying to find the source of a C2143

I am lost trying to find a C2143 missing ; before using Error in all of my cpp files.
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
///// main.cpp///////
#include <iostream>
#include <time.h>
#include "fight.h"
#include "player.h"
#include "zombie.h"

using namespace std;


int direction;
player R; //instance of player class
combat B; //instance of combat class
zombie E; //instance of zombie class





int main ()
{
	cout << "            Welcome to Z.E.T.A" << endl;
	cout << "     “ Zombie Elimination Training Academy ”" << endl;
	cout << "     You have been selected to attempt to " << endl;
	cout << "     enter this elite group. Your first" << endl;
	cout << "     task is to reach our training facility " << endl;
	cout << "     located at the old airport. You can" << endl;
	cout << "     take one weapon from those provided " << endl;
	cout << "     in the room. Good luck." << endl;
	cout << "     " << endl;
	cout << "     You see set out on a table." << endl;
	cout << "     a shotgun with 12 shells," << endl;
	cout << "     a 9mm pistol with 30 rounds, " << endl;
	cout << "     a chainsaw," << endl;
	cout << "     a M16 with 60 rounds " << endl;
	cout << "     and a hatchet. " << endl;
	cout << "     " << endl;
	cout << "     Choose your weapon. " << endl;
	cout << "     To choose your weapon," << endl;
	cout << "     enter 1 for the Shotgun, " << endl;
	cout << "       9 for the 9mm, " << endl;
	cout << "       2 for the chainsaw, " << endl;
	cout << "       16 for the M16 and " << endl;
	cout << "       3 for the Hatchet. " << endl;
	cout << endl;
	cin >> R.weapon; //weapon selection

			 switch (R.weapon)// iniatilize weapon variables
			{
			case  1: //shotgun selected
				R.prime = 4; //primary attack
				R.ammo = 12; //ammo tracking
				R.second = 1; //secondary or hand to hand attack
				R.hitchance = 0; //player base hit number
				break;

			case 9: //9MM pistol selected
				R.prime = 1; //primary attack
				R.ammo = 30; //ammo tracking
				R.second = 1; //secondary or hand to hand attack
				R.hitchance = 2; //player base hit number
				break;

			case 2: //Chainsaw selected
				R.prime = 3; //primary attack
				R.ammo = 1000; //ammo tracking
				R.second = 1; //secondary or hand to hand attack
				R.hitchance = 4; //player base hit number
				break;

			case 16: //M16 selected
				R.prime = 2; //primary attack
				R.ammo = 60; //ammo tracking
				R.second = 1; //secondary or hand to hand attack
				R.hitchance = 3; //player base hit number
				break;

			case 3: //Hatchet selected
				R.prime = 2; //primary attack
				R.ammo = 1000; //ammo tracking
				R.second = 2; //secondary or hand to hand attack
				R.hitchance = 4; //player base hit number
				break;
			
			}  
	


			  

			cout << "     Now that you have chosen your weapon it is" << endl;
			cout << "     now time to get to the airport."	<< endl;
			cout << "     Looking out the window you see a few zombies walking the streets. " <<endl;
			cout << "     This is not going to be as easy as it sounds." << endl;
			cout << "     You head out down the stairs to get to the facility." << endl; 
			cout << "     As you near the bottom floor you hear a faint shuffling sound." << endl;
			cout << "     Sounds like it is time to kill your first zombie." << endl;
			cout << "      " << endl;
		  B.fight_combat(); //combat function call
	
		
	
			cout << "After taking out that zombie you take a moment to collect yourself." << endl; 
			cout << "Walking out the door you see the main road to the airport " << endl;
			cout << "and the back streets and alleys.  The main road has zombies all over it and who knows what you may find taking the alleys. " << endl;
			cout << "Enter 1 to take the road or 2 to go the back way." << endl;
			cin >> direction;	
	
			if (direction == 1)//the hard way
				{
				cout << "You start making you way down the road listening carefully for signs of zombies. " << endl;
				cout << "After passing a few abandoned cars you see a zombie shuffling out from behind a car up ahead." << endl;
				B.fight_combat(); //call combat function 

			if (E.zombiehealth == 0) //zombie dead move on 
				cout << "Well hopefully all that noise doesn’t attract too much attention." <<endl;
				cout << "Heading down the road a bit faster now more and more zombies are coming out behind you." << endl;
				cout << "As you near the entrance of the airport you see 3 zombies chewing on a corpse in the road." << endl; 
				cout << "Looks like you have one more big fight ahead of you." << endl;
				B.fight_combat(); // call combat function
			if (E.zombiehealth == 0)// zombie dead move on 
				B.fight_combat(); //call combat function 
			if (E.zombiehealth == 0) // zombie dead move on 
				B.fight_combat(); // call combat function 
			if (E.zombiehealth == 0) //zombie dead move on
				cout << "Well you somehow managed to beat those zombies. Dragging yourself through the gate you feel somehow relived." << endl;
				cout << "A man in a military uniform walks up to you. " << endl;
				cout << "Well done looks like you have what it takes to help us rid the world of this zombie menace." << endl;
				cout << "Welcome to Z.E.T.A." << endl;
				cin.get();
				cin.get();
				return 0;
				}	
			      //End the hard way

		if (direction == 2) //The easy way
		{
			cout << "Twisting through the side streets you can hear the zombies everywhere but so far have yet to see any." << endl;
			cout << "Suddenly one stumbles out form a dark corner." << endl;
			B.fight_combat(); //call the combat function 
		if (E.zombiehealth == 0) // zombie dead move on 

			cout << "Thankfully you know your way around town. " << endl;
			cout << endl;
			cout << "Taking a few more turns you see a zombie crawling out of a house." << endl;

			B.fight_combat(); //call the combat function

		if (E.zombiehealth == 0) // zombie dead move on 
			cout << "Just when you think you might have been better off taking the main road you spot the airport employee parking garage. " << endl;
			cout << "Thinking to yourself, wasn’t there a tunnel leading in to the airport in there." <<endl;
			cout << "Making your way through the garage you manage to find the tunnel with little difficulty. " << endl;
			cout << "As you approach the tunnel entrance you see a zombie, who looks like a pilot scratching at the door. " << endl;

			B.fight_combat(); //call the combat function 

		if (E.zombiehealth == 0) //zombie dead move on 
			cout << "After dispatching the zombie pilot you try to open the door only to find it takes a special key. " << endl;
			cout << "Searching around you notice a key card on the pilots belt. Using it to open the door you run through the tunnel to the airport." << endl;
			cout << "When you come out you almost run in to a man in a military uniform. He looks at you and smiles. " << endl;
			cout << "Well done you will do well here. We have needed someone like you for some time now. " << endl;
			cout << "Let’s get you cleaned up and start you training. " << endl;
			cin.get();
			cin.get();
			return 0;
			//end the easy way
		}
			return 0;//end of the intro more story in the works

}	

The rest of the program
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
////Player.cpp///////
#include <iostream>
#include "player.h"
#include "fight.h"
#include "zombie.h"

using namespace std;

player::player(void)
{
	playerhealth = 10; //Player Health declared
}
player::~player()
{
}

player P; //instance of player clas
zombie G; //instance of zombie class
combat Z; //instance of combat class

int playerAttack() //player Attack function 
{
	cout << "               Choose your attack. " << endl;
	cout << "     Enter 1 to shoot or 2 of Hand to Hand" << endl;
	cout << " " << endl;
	//cout << " prime is" << this -> prime << endl;
	//cout << "ammo is "<< this -> ammo << endl;
	//cout << "second is " << this -> second << endl;
	//cout << "hitchance is " << this -> hitchance << endl;
	//cout << "     player health is " << P.playerhealth << endl;
	//cout << "     zombie health is " << G.zombiehealth << endl;
	//cout << "randhit mod is" << randhitmod << endl;
	cin >> P.attack; //player chooses primary or secondary or hand to hand attack

				 

		   switch (P.attack)//if (A.attack == 1)

		   {		

			case 1:			  //pirmary attack
				if (Z.randhitmod + P.hitchance >= Z.hit, P.ammo --)
					{
						cout << "You hit the zombie" << endl; //Player hit zombie
						G.zombiehealth = G.zombiehealth - P.prime;
					}
				else;//if (randhitmod + this -> hitchance < A.hit, this -> ammo --)
				
					{
						P.ammo--;
						cout << "You missed the zombie" << endl; // player misses zombie
					}
				

				  if (P.ammo == 0)	 //ammo check
						{
						cout << "Click, click you are out of ammo." << endl;
						P.hitchance = -9999;
						}
		//if ( A.attack == 2)
			case 2:			 //secondary attack

				if (Z.randhitmod +  P.hitchance >= Z.hit)
					{
						cout << "You hit the zombie" << endl;
						G.zombiehealth = G.zombiehealth -  P.second;
					}
				if (Z.randhitmod +   P.hitchance < Z.hit)
					{
						cout << "You missed the zombie" << endl;
					}
				
			default:
				cout << "Please enter either 1 or 2." << endl;
				break;

		   }
		   return 0;
}
/////fight.cpp//////
#include <iostream>
#include "fight.h"
#include <time.h>
#include "player.h"
#include "stdlib.h"
#include "zombie.h"

using namespace std;

 
 combat A; //instance of combat class
 zombie D; //instance of zombie class
 player Q; // instance of player class

combat::combat(void)
{
	hit = 10; //int hit declared
}
combat::~combat()
{
}


int combat::fight_combat() //combat function
{
	
	
	srand(time(NULL)); // random number generator
	int randhitmod = rand() % 10 +1; //random number range

	 Q.playerAttack(); // call playerAttack function
	 D.deadAttack(); // call zombieAttack function
	
			  if (Q.playerhealth <= 0)		  //game over
			{
			cout << "The zombie pulls you to the ground and starts to devour your flesh. Hopefully you will not feel this too long. " << endl;
				cout << "Game over" << endl;
				 cin.get();
				cin.get();
				return 0;
			}

			  else (D.zombiehealth <= 0);		  //move on
		{
			cout << "That was close hopefully there will not be too many of those." << endl;
		}
			while (Q.playerhealth >= 0, D.zombiehealth >= 0) //Loop until one or the other is dead
			cin.get();
			cin.get();
	return D.zombiehealth;

}
/////zombie.cpp//////
#include <iostream>
#include "zombie.h"
#include "player.h"
#include "fight.h"
using namespace std;

player C; //instance of player class
zombie F; //instance of zombie class
combat Y; //instance of copmbat class

zombie::zombie(void)
{
	zombiehitmod = 1; //zombies modifier to hit a target declared
	zombiechop  = 1; //zombie damage declared
	zombiehitchance = 1; //zombie base chance to hit declared
	zombiehealth = 3; // zombie health declared
}
zombie::~zombie()
{
}

int deadAttack()
//zombie attacks
{
	if (F.zombiehitmod + Y.randhitmod >= Y.hit) //zombie hits player
		{
			cout << "The zombie hits you" << endl;
			C.playerhealth = C.playerhealth - F.zombiechop;
		}
	if (F.zombiehitmod + Y.randhitmod <= Y.hit) //zombie deals damage
		{
			cout << "The zombie missed you" << endl;
		}
	return 0;
}
////fight.h///////
#include <iostream>


#ifndef fight_h
#define fight_h
using namespace std;


class combat
{
public:
	combat(void);
	~combat(void);
	
	int randhitmod;	//random number generator
	int hit; //number needed to hit a target currently is 10
	int fight_combat(); // combat function
};
#endif
//////player.h//////
#include <iostream>


#ifndef player_h
#define player_h

using namespace std;

class player
{
public:
	player(void);
	~player(void);
	int weapon; //weapon selection variable
	int playerhealth; //Player health variable
	int prime; //primary attack variable
	int second; //secondary attack variable
	int ammo;  //Ammo chack variable
	int hitchance; //Weapon modifier to hit a target
	int attack; //Attack selection variable
	int playerAttack(); //playerAttack function

};
#endif
///zombie.h///////
#include <iostream>



#ifndef zombie_h
#define zombie_h

using namespace std;

class zombie
{
public:
		zombie(void);
		~zombie(void);
		int zombiehealth; //zombies health variable
		int deadAttack(); //zombie attack function
		int  zombiehitmod ; //zombie modifier to hit a target
		int	 zombiechop ; //zombie damage
		int	 zombiehitchance ; // zombie base to hit a target
	
};
#endif 
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
class zombie
{
public:
		zombie(void);
		~zombie(void);
		int zombiehealth; //zombies health variable
		int deadAttack(); //zombie attack function
		int  zombiehitmod ; //zombie modifier to hit a target
		int	 zombiechop ; //zombie damage
		int	 zombiehitchance ; // zombie base to hit a target
	
} //<<<< here
#endif 
Last edited on
Where exactly in that class is the issue?
never mind i see it
Alright now after fixing that problem, I have a stupid run time problem I can seem to solve. The fight.cpp does not loop or exit. Any way to fix this.
Topic archived. No new replies allowed.