Skip to main content
gamedev.net
🔒 Locked

Header problems

Started by Nazrix 4 replies 250+ views
Original Post
Nazrix
Nazrix
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
Nazrix
Nazrix
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
antareus
antareus
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
Nazrix
Nazrix
oh I see...

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

-[Image Sig removed by Run pending staff/mod consultation]
-ryan@lecherousjester.com
Nazrix
Nazrix
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.