October 2004
Intermediate to advanced
240 pages
6h 22m
English
Behave responsibly: Ensure that each header you write is compilable standalone, by having it include any headers its contents depend upon.
If one header file won’t work unless the file that includes it also includes another header, that’s gauche and puts unnecessary burden on that header file’s users.
Years ago, some experts advised that headers should not include other headers because of the cost of opening and parsing a guarded header multiple times. Fortunately, this is largely obsolete: Many modern C++ compilers recognize header guards automatically (see Item 24) and don’t even open the same header twice. Some also offer precompiled headers, which help to ensure that often-used, ...