Hi,
I have an error here that's confusing me, it looks like a include-problem.
I have the following classes:
NPC
Animal (is a NPC)
AI
AnimalAI (is a AI)
Environment (has a list of Animal pointer)
NPC has a pointer to AI and AI has one to NPC.
Animal inherits the NPCs AI pointer, but I make it an AnimalAI pointerby overriding the getter, wich should work because AnimalAI is a subclass of AI (co-variant). I do the same with the AI's NPC-getter
There are 26 Errors. Mostly telling that I'm missing ';' before '*'. As this happens in the line where "AnimalAI* getMyAnimal();" is declared, I guess it's just a symptom of this declaration-confusion
In Animal it's "base class is undefined" (so NPC) and an error that occurs beacuse he doesn't accept AnimalAI as an AI, so the co-variant "rule" doesn't work.
Here the code's includes: (Am I missing something, or is the problem bigger?)
Environment:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include <list>
#include "Animal.h"
#include "Stone.h"
#include <iostream>
using namespace std;
class NPC;
class Environment
{...};
#endif
|
NPC:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#ifndef NPC_H
#define NPC_H
#include "Object.h"
#include "AI.h"
using namespace std;
class Environment;
class AI;
class NPC{
...
virtual AI* getMyAI();
};
|
Animal:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#ifndef ANIMAL_H
#define ANIMAL_H
#include "NPC.h"
#include "AnimalAI.h"
class AI;
class NPC;
class Animal :
public NPC
{
...
AnimalAI* getMyAI();
};
|
AI:
1 2 3 4 5 6 7 8 9 10 11
|
#ifndef AI_H
#define AI_H
#include "Environment.h"
class Environment;
class NPC;
class AI
{
...
virtual NPC* getMyAnimal();
}
|
AnimalAI:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#ifndef ANIMALAI_H
#define ANIMALAI_H
#include "AI.h"
#include "Animal.h"
class Environment;
class AnimalAI :
public AI
{
...
Animal* getMyAnimal();
};
|
thanks for help,
nonsence90