Advertisement

Header Files

Started by November 06, 2000 07:44 PM
0 comments, last by Spanky 24 years, 2 months ago
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?
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.

This topic is closed to new replies.

Advertisement