Defining private static class member

Posted by mnn on Stack Overflow See other posts from Stack Overflow or by mnn
Published on 2011-01-02T18:28:10Z Indexed on 2011/01/02 18:54 UTC
Read the original article Hit count: 215

Filed under:
|
|
|
class B { /* ... */ };

class A {
public:
    A() { obj = NULL; }
private:
    static B* obj;
};

However this produces huge mass of linker errors that symbol obj is unresolved.

What's the "correct" way to have such private static class member without these linker errors?

Edit: I tried this:

B *A::obj = NULL;

but I got about same amount of linker errors however this time about already defining A::obj. (LNK2005).

Also I get LNK4006 warnings, also about A::obj

© Stack Overflow or respective owner

Related posts about c++

Related posts about class