当我尝试在player.h
中加入battlefield.h
时,会发生此错误:
error C2079: 'BattleField::firstplayer' uses undefined class 'Player'.
真的不明白为什么会发生这种情况,我通过网络搜索过,看到了圆形图案问题,但这对我来说并不是很清楚。任何帮助,将不胜感激。
Player.h:
#include <iostream>
#include <fstream>
#ifndef PLAYER_H
#define PLAYER_H
#include "classDeck.h"
class Player
{
private:
char* Name;
double Health;
double Energy;
public:
Deck playerdeck;
Player();
Player( char* Name, double Health, double Energy );
Player( const Player& play );
Player& operator= ( const Player & play );
~Player();
void set_Name( char* Name );
void set_Health( double val );
void set_Energy( double val );
void print_Player()const;
char* get_Name()const
{
return Name;
}
double get_Health()const
{
return Health;
}
double get_Energy()const
{
return Energy;
}
};
#endif
battleField.h:
#include <iostream>
#include <fstream>
#ifndef BATTLEFIELD_H
#define BATTLEFIELD_H
#include "classDeck.h"
#include "Player.h"
class BattleField
{
private:
Deck firstPlayer; //TESTE NA PURVI IGRACH
Deck secondPlayer; //TESTE NA VTORI IGRACH
Deck semetary; //MASIV Grobishte
Player firstplayer1;
Player secondplayer2;
public:
Deck playedCards; //MASIV OT IZIGRANI KARTI
BattleField(); // PODRAZBIRASHT SE KONSTRUKTOR
~BattleField(); //DESTRUKTOR
BattleField( const BattleField& battle ); // KOPIRASHT KONSTRUKTOR
BattleField& operator= ( const BattleField& battle ); //OPERATOR =
void insertLeftPlayDeck(const Deck& deck); // ZADAVAME TESTE NA EDINIQ IGRACH
void insertRightPlayDeck(const Deck& deck); //ZADAVAME TESTE NA DRUGIQ IGRACH
void Battle(); //FUNKCIQ, V KOQTO DVE KARTI SE BIQT
void display(); //PRINTIRASHTA FUNKCIQ
void Serializer(); //SERIALIZIRASHTA
const Deck get_semetary() const;
const Deck get_playedCards()const;
const Deck get_firstPlayer() const;
const Deck get_secondPlayer() const;
};
#endif