What is the difference between static const and const?
For example:
static const int a=5;
const int i=5;
Is there
The difference is the linkage.
// At file scope
static const int a=5; // internal linkage
const int i=5; // external linkage
If the i object is not used outside the translation unit where it is defined, you should declare it with the static specifier.
This enables the compiler to (potentially) perform further optimizations and informs the reader that the object is not used outside its translation unit.