extern
. Each
variable declaration informs the compiler that there is a variable
with a particular name of a particular type, but does not indicate
where it is in memory.
enum
definitions: enumerated types permit the use of
symbolic constants instead of literal constants.
class
or struct
definitions. These definitions are
not stored in an object file, therefore they can and must be
defined in a header file.
The most important thing to remember is that a header file should not
include function definitions (with the curly braces), or variable
definitions (without extern
). Both function and variable definitions
are stored in object files. If multiple files have definitions of the
same name, the linker complains and no executable will be generated.
Copyright © 2006-09-07 by Tak Auyeung