Skip to main content
GameDev.net gamedev.net
🔒 Locked

Header question again

Started by Talib Jul 6, 2004 at 1:21 PM 1 replies 350+ views
Original Post
Talib
Talib
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
Try, try and fucking try again.
chollida
chollida
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
ApochPiQ
ApochPiQ
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.