I need to make no bigger project "Army", everyone has their own abilities, etc. But for some reason, when compiling, I write that I did not declare SpellCaster and Unit. And I cannot understand where I need to declare them, or in what error?
In file included from Unit.h:5:0,
from Unit.cpp:1:
SpellCaster.h:25:22: error: 'Unit' has not been declared
virtual void attack(Unit& enemy);
^~~~
In file included from SpellCaster.h:6:0,
from SpellCaster.cpp:1:
Unit.h:28:25: error: 'SpellCaster' has not been declared
virtual void attack(SpellCaster& spellcaster);
This is my Unit.h :
#include <iostream>
#include "SpellCaster.h"
class UnitIsDead {};
class Unit {
private:
int hpLimit;
int dmg;
int hp;
std::string name;
void ensureIsAlive();
public:
Unit(int hpLimit, int dmg, const std::string& name);
~Unit();
int getDamage() const;
int getHP() const;
int getHpLimit() const;
const std::string& getName() const;
void takeDamage(int dmg);
virtual void attack(Unit& enemy);
virtual void attack(SpellCaster& spellcaster);
void counterAttack(Unit& enemy);
};
and my SpellCaster.h :
#include "Unit.h"
class SpellCaster{
private:
int hp;
int dmg;
int hpLimit;
std::string name;
public:
SpellCaster(int hpLimit, int dmg, const std::string& name);
~SpellCaster();
int getDamage() const;
int getHP() const;
int getHpLimit() const;
const std::string& getName() const;
void takeDamage(int dmg);
virtual void attack(SpellCaster& spellcaster);
virtual void attack(Unit& enemy);
};
I'll be very thankful