-
May 21st, 2013, 03:46 AM
#1
Incomplete type is not allowed
Code:
#include "..\Objects\Objects.h"
class Idle;
class Objects;
class Goods;
class Activity
{
public:
Objects *Actor;
Goods *Target;
Activity() : Actor(0), Target(0) { }
Activity( Objects* actor, Goods* target )
{
Actor = actor;
Target = target;
}
virtual bool OnUpdate(float seconds) = 0;
void Update(float seconds)
{
if (OnUpdate(seconds))
{
Actor->activity = new Idle(Actor, NULL); <<<< incomplete type is not allowed
// activity is of type Activity *
}
}
Activity *FindBestActivity(Objects *actor)
{
return NULL;
}
};
/////////////////////
#include "..\Objects\Objects.h"
#include "Activity.h"
#define MAX_IDLE_TIME 8
#define ACTIVITY_IDLE_ENERGY 1.0
class Objects;
class Activity;
class Idle : public Activity
{
private:
float mTimeInIdle;
public:
Idle() : mTimeInIdle(0) { }
Idle(Objects *actor, Goods *target) : Activity(actor, target)
{
}
bool OnUpdate(float seconds)
{
mTimeInIdle += seconds;
if (mTimeInIdle >= MAX_IDLE_TIME)
{
Actor->activity = FindBestActivity(Actor);
}
Actor->energy += ACTIVITY_IDLE_ENERGY * seconds;
return false;
}
};
Please help fix this problem.
Thanks
Jack
-
May 21st, 2013, 03:57 AM
#2
Re: Incomplete type is not allowed
You cannot access Actor->activity unless the definition of Objects is known. Perhaps you should define the Update member function in a source file instead, where the header containing the definition of Objects can be included (presumably you are only using a forward declaration here to break a recursive dependency or something).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|