Sign in to follow this  

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

This topic is 4281 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
(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

This topic is 4281 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this