cppsks wrote:
namespace test
{
static const int num = 10;
const int num2 = 20;
}
What exactly is the difference here?
Absolutely none.
Which is preferred (if both mean the same)?
The second form, probably. It is shorter.
If you were trying to create a header file that is compilable in both C
and C++ code, then maybe it would make sense to use the explicit
'static', since in C constant objects have external linkage by default.
But apparently you are not trying to do that.
--
Best regards,
Andrey Tarasevich