Jump to content
  • Advertisement
Sign in to follow this  
Makkedah

All headers in one file, how do I fix this?

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

So I have lots of class declarations that should each be a file in itself, but instead they are all combined together in the same big header file. This is so, because whenever they have their own header files, they say that the classes in the big header file are undefined, even though I #include the header. How can I seperate these class declarations? I'm using Visual C++.NET 2003.

Share this post


Link to post
Share on other sites
Advertisement
(1) Provide include guards in your header files so they are idempotent.
(2) Use forward declarations of your classes where possible (ie. if they are only used by pointer or reference).
(3) Always include all header files necessary in all header files and implementation files, but only those that are necessary (see (2) above). Don't worry about circular dependencies (see (1) above).

Now, you may have to google for definitions of idempotence and forward declarations, but once you've matered them, you will never have header file problems again.

Share this post


Link to post
Share on other sites
Alright, the forward declarations were the problem. I wasn't being specific enough when I tried them before. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!