Please help, class is incorrect.

closed account (LAfSLyTq)
Code:
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
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;

	int damageDealt;
	char name[10];
	char Action;
	 
void namephase()
	{
		cout<<"\n\nEnter Your name."<<endl;
	cin>>name;
	cout<<"Your name is "<<name<<"?\n 1=Yes 2=No"<<endl;
	cin>>Action;
	if(Action=='1')
	{
		cout<<"Very well\n"<<endl;
	}
	if(Action=='2')
	{
		cout<<"What is your name?"<<endl;
		cin>>name;
		cout<<"Your name is now "<<name<<"!\n"<<endl;
	}
	else
	{
		cout<<"Please enter a valid name!"<<endl;
		namephase();
	}
	}
class Boar;
class Player;
void battlePhase();
class Characters
{
	class Player1
	{
public:

	int health;
	int exp;
	int level;
	int atk;
	Player1 (bool Player1)
	{
		health = 20;
		level = 1;
		exp = 0;
		atk = 10;
		damageDealt = atk;
	};
	class Boar
{
public:

	int health;
	int level;
	int atk;
	Boar(bool Boar)
	{
		health = 20;
		level = 1;
		atk = 10;
	};
	void battlePhase()
{
cout <<"You have run into a Boar!\nWhat do you want to do?\n1=Attack "<<endl;
cin >> Action;
if ( Action == '1' || Action == 'i' )
{
cout<<name<<" attacked enemy for " <<atk<< endl;
Boar::health = Boar::health - damageDealt;
if ( damageDealt < 0 )
{
damageDealt = 0;
cout<<"No damage!"<<endl;
}
if ( damageDealt == 0 )
{
cout <<"No damage!"<<endl;
}
if ( damageDealt > 0 )
{
cout << "enemy" << " took " << damageDealt << " damage!";
}
if(Boar::health == 0)
{
	cout<<"enemy has died!"<<endl;
	cout<<"you have gained "<<"50"<<" exp!"<<endl;
	system ("CLS");
	Player1::exp += 50;
}
else
{


Player::exp is unidentified because it thinks i have to do it as Boar::exp.
please help me out here.
Indent your code properly. This is a nightmare to read.

Player::exp is unidentified

Player1::exp is non-static. You must instantiate a Player1 object from class Player1 in order to modify your exp member.
Topic archived. No new replies allowed.