1. There seem to be a number of opinions about how a const int (NOT a class member) should be declared & defined.
For example, in this thread
Const vs define and use of const
Elysia says "Don't put any variables in headers. Define them in a .cpp file and use extern in the header files."
In this one, Daved recommended defining a constant in a header file but enclosed in an unnamed namespace, ChaosEngine says to define it in a header file (wrapped in a #ifndef ... #endif block) as static const int, and CornedBee says that neither the static nor the namespace is necessary.
.h files: "constant already defined"
I didn't find any clear statement on this from either Salem or Prelude. I'd love to get some further guidance on this -- is a consensus possible?
2. Sort of related to the above, does "static" have any significance in C++ when used OUTSIDE of any class definition? Is there any difference between a global "static const int x" vs. a global "const int x"?
sums up the reasons to prefer using const over #define, but it also says that there are cases when #define is preferable. So, when is #define preferable?