Jump to content
  • Advertisement


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

The Canary Man

Header Inclusion problems

This topic is 6065 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

You have a recursive dependency problem : CWrestler needs CTeam and vice-versa.

wrestler.h includes team.h which tries to include wrestler.h to get the definition of CWrestler, but the include guard prevents it. So team.h never gets the definition of CWrestler.

You should restructure your classes to use references, or pointers to the other class instead of an actual instance of the object. When you have an actual instance, the compiler needs to know the size of the data structure, and thus needs the complete definition. When you have a reference or a pointer, it justs takes into account the space for the 32-bit pointer.

Therefore, you can just tell it that there is a class named CTeam or CWrestler (by writing ''class CTeam;'' or ''class CWrestler;'') and not include the whole definition.

It is usually considered bad form to #include headers in headers, unless you REALLY cannot do without them. Just declare the needed symbols.

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!