Header problems

Started by
4 comments, last by Nazrix 21 years, 3 months ago
I'm having a problem with including headers:
    
// Npc.h


#include "mission.h"


class Npc : public Person
{

Mission *currMission;

  

  
      
// Mission.h


#include "npc.h"

class Mission
{
   public:
	
   Npc *told,  //npc that told the npc to do the mission

       *involved; //npc doing the mission


	
    
So, basically each header needs the other and that seems to be giving me problems. If Npc.h includes mission.h, mission.h doesn't know what the class Npc is. A CRPG in development... Need help? Well, go FAQ yourself. [edited by - Nazrix on December 23, 2002 4:39:40 PM]
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Advertisement
The errors are:


Compiling...
main.cpp
c:\documents and settings\shizzle nizzle\my documents\vcprojects\backed up ai\mission.h(13) : error C2143: syntax error : missing ';' before '*'
c:\documents and settings\shizzle nizzle\my documents\vcprojects\backed up ai\mission.h(13) : error C2501: 'Npc' : missing storage-class or type specifiers
c:\documents and settings\shizzle nizzle\my documents\vcprojects\backed up ai\mission.h(13) : error C2501: 'told' : missing storage-class or type specifiers
c:\documents and settings\shizzle nizzle\my documents\vcprojects\backed up ai\mission.h(14) : error C2501: 'involved' : missing storage-class or type specifiers


[edited by - Nazrix on December 23, 2002 4:41:41 PM]
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
You have circular include problems.

Use forward declarations. I''m not sure how you choose which one goes where though, hopefully someone will clarify.

E.g. in mission.h you can put:

class Npc;

before everything and not include the "npc.h" file explicitly.

Oh and watch the public members
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
oh I see...

thanks for the info
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Weird, seeing an old-timer posting help for a basic topic.

-[Image Sig removed by Run pending staff/mod consultation]
-ryan@lecherousjester.com
yeah you'd be suprised how little I know.

[edited by - Nazrix on December 23, 2002 6:26:50 PM]
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi

This topic is closed to new replies.

Advertisement