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

Header Files

Started by Spanky Nov 6, 2000 at 7:44 PM 0 replies 500+ views
Original Post
Spanky
Spanky
Here''s a question. Lets say I have 3 different files that include about 10 files each. Should I just keep them inside the file that uses them or should I make one file with all the header files that I need for the entire project and have the 3 cpp files just include that one file? What are the pro''s and con''s, speed difference, size differences if I do this. Any suggestions?
SteveC
SteveC
You should only ever include header files that are needed for the current translation unit ( .cpp file )

Including additional header files takes much more time to parse and creates unnecessary ( and potentially unknown ) physical dependencies on other header files.

Some folks get around this by using a precompiled header to address the speed issue, but that just ends up promoting poor physical design.

Take a look at the Lakos book "Large Scale C++ Software Design"
for more info on physical design.

Topic Locked

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

Sign in to reply to this topic.