Variable declarations in header files - static or not?

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2008-09-18T13:32:05Z Indexed on 2010/04/27 2:23 UTC
Read the original article Hit count: 274

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c

    Related posts about static