Static class members in different T.U. ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having problems using static members of a class (largely HANDLEs of various sorts) as static class members of a class. It compiles OK but the linker complains of unresolved external symbol. Declaring them as just normal globals or member variables doesn't cause the said problem

I've got them such a
static HCURSOR g_hcWait
...
MyClass::g_hcWait = LoadCursor(NULL, IDC_WAIT); //(yes I do use LoadImage really I just put that to be brief

this is something that should logically be shared across all members of a class, am I doing it wrong?
 
You actually described the issue: you just declared them, but did not define
them.

Somewhere in global scope you need to add:

HCURSOR MyClass::g_hcWait;

Ronald Laeremans
Visual C++ team

Bonj said:
I'm having problems using static members of a class (largely HANDLEs of
various sorts) as static class members of a class. It compiles OK but the
linker complains of unresolved external symbol. Declaring them as just
normal globals or member variables doesn't cause the said problem.
I've got them such as
static HCURSOR g_hcWait;
...
MyClass::g_hcWait = LoadCursor(NULL, IDC_WAIT); //(yes I do use LoadImage
really I just put that to be brief)
this is something that should logically be shared across all members of a
class, am I doing it wrong?
 
Back
Top