• Advertisement
Sign in to follow this  

Header question again

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

Hi what does this mean?: You don't have to include your custom header, just forward declare it to cut down on a lot of compile times when changing a single line because it stops a chain from occuring if everything includes something else. Thanks Talib

Share this post


Link to post
Share on other sites
Advertisement
It means in your .h file you don't have to inlcude a header file for any pointers you use just forward declare them

ie for
class foo;

class bar
{
foo* m_foo;
}

then in your cpp add #include "foo.h". One reason to do this is to cut down on compile times. If foo.h is changed then the compiler needs to touch your bar.h file. If you forward declare the class then it only needs to touch your cpp file.

You can see how touching the .h file would increase compile times as the compiler would then need to recomiple every file that included your bar.h file.

Cheers
Chris

Share this post


Link to post
Share on other sites
A forward declaration is really the same thing as a prototype, except with a struct or class (and perhaps a few other things) instead of a function.

Share this post


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

  • Advertisement