Hello everyone,
I'm a novice programmer and am having trouble with a text-adventure game I am programming. There are two classes, Hero and Monster, that contain functions that I want to be able to pass pointers to objects of the opposite class into, but the compiler complains that it cannot recognize the identifiers. I have included both "Hero.h" and "Monster.h" in each cpp file, and I get different compiler errors depending on the order I include the files, so I'm assuming it's a scoping issue. I can't figure out how to resolve it though. If anyone could give me some suggestions I would appreciate it. I've included some of the code to help clarify.
class Hero
{
public:
Hero();
void nameHero(string n);
void attack(Monster *monster);
...
}
class Monster
{
public:
Monster();
void nameMonster(str ing n);
void attack(Hero *hero);
...
}
I keep getting errors in the declaration of the 'attack' fuction for each class.
I'm a novice programmer and am having trouble with a text-adventure game I am programming. There are two classes, Hero and Monster, that contain functions that I want to be able to pass pointers to objects of the opposite class into, but the compiler complains that it cannot recognize the identifiers. I have included both "Hero.h" and "Monster.h" in each cpp file, and I get different compiler errors depending on the order I include the files, so I'm assuming it's a scoping issue. I can't figure out how to resolve it though. If anyone could give me some suggestions I would appreciate it. I've included some of the code to help clarify.
class Hero
{
public:
Hero();
void nameHero(string n);
void attack(Monster *monster);
...
}
class Monster
{
public:
Monster();
void nameMonster(str ing n);
void attack(Hero *hero);
...
}
I keep getting errors in the declaration of the 'attack' fuction for each class.
Comment