More About Header Files
- They are used to store information common to multiple source
files
- Source files can use the information by #includeing
the header file
- The use of header files reduces duplication and allows for easier
modification because a constant or type declaration need only be changed
in one
place
- Header files should only contain:
- Definitions of constants
- Type declarations (typedefs)
- Macro definitions
- Extern declarations
- Function declarations (prototypes)
- struct and class definitions
- Header files should not contain:
- Any executable code i.e., no function definitions
- Definitions of variables. Otherwise the inclusion of the header
file in multiple source files will cause a multiple definition linkage
error
Back to Previous Page
Document:
Local Date:
Last Modified On: