Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nazrix

Header problems

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!