Variable declarations in header files - static or not?
- by Rob
When refactoring away some #defines I came across declarations similar to the following in a C++ header file:
static const unsigned int VAL = 42;
const unsigned int ANOTHER_VAL = 37;
The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possible due to the classic #ifndef HEADER #define HEADER #endif trick (if that matters).
Does the static mean only one copy of VAL is created, in case the header is included by more than one source file?