Sign in to follow this  

Header question again

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
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.


Share this post

Link to post
Share on other sites

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