Do not define variables in header files. When you do you get a new variable every time you include that header. What you want is one variable fro the entire program.
Header files are for declarations only.
Define your const in an implementation file:
- MyTestGlobals.cpp:
-
-
extern const char* temp = "Temp";
This will create temp as a sharable const variable.
Then in your header file:
- MyTestGlobals.h
-
-
extern const char* temp;
Finally, include your header:
#include MyTestGlobals.h
class MyClass
{
private:
public:
};