Hi, I have a problem with two classes who both has instances to each other.
Here are the header files...
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include <vector>
#include "item.h"
#include "actor.h"
namespace game{
class Environment{
public:
Environment(){}
Environment(std::string name_, std::string description_);
enum directions {
north = 0,
north_east = 1,
east = 2,
south_east = 3,
south = 4,
south_west = 5,
west = 6,
north_west = 7
};
void add_item(Item & it);
void remove_item(Item & it);
void add_exit(const int position, const Environment & env);
void remove_exit(const int position);
void add_actor(Actor & act);
void remove_actor(Actor & act);
protected:
std::string name, description;
std::vector<Item> items;
bool existing_exits[8];
Environment * exits;
std::vector<Actor> actors;
};
}
#endif
#ifndef ACTOR_H
#define ACTOR_H
#include <string>
#include "environment.h"
namespace game{
class Actor{
#define max_level 20
protected:
std::string name, description, type;
int vitality, strength, level, dexterity;
bool evil;
Environment current_location;
public:
const int get_vitality() const{ return vitality; }
const int get_strength() const{ return strength; }
const int get_dexterity() const{ return dexterity; }
const int get_level() const{ return level; }
const std::string get_name() const{ return name; }
const std::string get_description() const{ return description; }
const std::string get_type() const{ return type; }
const bool is_evil() const{ return evil; }
const bool operator==(const Actor & ref) const;
//const Environment & get_location() const{ return current_location; }
void increase_level(int lev);
//virtual const bool attack(Actor & other) const = 0;
//virtual void take_damage(const int damage) = 0;
const float chance_to_hit(const Actor other) const;
};
}
#endif
I get the following errors when i compile
wpa-n2-53:lab3 sason$ make
g++ -c actor.cpp
In file included from actor.h:6,
from actor.cpp:2:
environment.h:34: error: ‘Actor’ has not been declared
environment.h:35: error: ‘Actor’ has not been declared
environment.h:44: error: ‘Actor’ was not declared in this scope
environment.h:44: error: template argument 1 is invalid
environment.h:44: error: template argument 2 is invalid
make: *** [all] Error 1
How do i let the class know that there is a "Actor" type?