I'm currently using a namespace to hold a set of variables which should be usable by all classes in the project. Some variables should be constants and are defined in the namespace itself, for others the value should be assigned later. Example:
// MyProject.h
namespace MyNameSpace {
extern const double a = 1.0;
extern const int b = 2;
extern double c;
extern int d;
}
// MyProject.cpp
MyNameSpace::c = 3.0;
MyNameSpace::d = 4;
However this returns the errors for the variables c and d:
error LNK2001: unresolved external symbol "int MyNameSpace::c"
error LNK2001: unresolved external symbol "double MyNameSpace::d"
What is the correct way of assigning values to external variables outside of the namespace after declaration?