Class name not being Identified by the program

I was making a text based game in the console.

I designed a class named Player in a file Player.h
and a class named Moves in another file named Moves.h

Both are included in side the other (Player.h in Moves.h and vice-versa)
I did this because I needed some functions to retrieve data from the other class.

Like to see if the Player has energy to do the specific move in the move class, I did it like this:
bool Move(Player&);
And similarly the Player will have a set of Moves allocated to it, so the Player class has an object of type Moves.

But on compilation, I get the following errors:
fighters.h(16): error C2065: 'Moves' : undeclared identifier
moves.h(21): error C2061: syntax error : identifier 'Player'

The Lines where they have been used:
Move.h
 
bool Cast(Player&);


Player.h
 
vector<Moves> move;


Now I have checked that both the files have been included already.

Can any one Help me find the problem?
I can't see any reason for these errors to appear at all.
Can you post more code please.
Here:
Fighters.h
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
#pragma once

#include "default.h"
#include "Moves.h"
#include "Enumerations.h"

class Fighters
{
private:
	string Name;
	
	AbilityType Ability;
	vector<Moves> move;      //ERROR here
	int Health;
	int const MaxMana;
	int Mana;
	int Speed;
	Stats Status;
public:
	Fighters(int maxmana = 0);
	
	int rHealth() {return Health;}
	int rMana() {return Mana;}
	int rSpeed() {return Speed;}
	Stats rStatus() {return Status;}
	AbilityType rAbility() {return Ability;}

	void LoseMana(int a) { Mana -= a;}
	void GainMana(int a) { Mana -= a;}

	void LoseHealth(int a) { Health-= a;}
	void GainHealth(int a) { Health -= a;}

	void LoseSpeed(int a) { Speed -= a;}
	void GainSpeed(int a) { Speed -= a;}

};


Moves.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "default.h"
#include "Fighters.h"
#include "Enumerations.h"

class Moves
{
private:
	string Name;
	Movetype MoveType;
	AbilityType Element;
	int Damage;
	Special Special_Effect;
	int ReqMana;
public:
	Moves();
	int Cast(Fighter&, Fighter&);       //ERROR here
};


Enumerations includes all the enums I have used (Like Special, Movetype...)
Last edited on
Someone?
closed account (1vRz3TCk)
You could try:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "default.h"
//#include "Fighters.h"  // include this in the implementation file
#include "Enumerations.h"

class Fighter; 

class Moves
{
private:
	string Name;
	Movetype MoveType;
	AbilityType Element;
	int Damage;
	Special Special_Effect;
	int ReqMana;
public:
	Moves();
	int Cast(Fighter&, Fighter&);       //ERROR here
};
Last edited on
Done that.
That worked Great.
Many, Many, thank.
Topic archived. No new replies allowed.