I have a static member in my class. It's declared and defined:
In my header:
class Bla {
...
static Bla* instance;
...
};
In my implementation file:
Bla::Bla* instance = 0;
But ld doesn't seems to like it:
release/bla.o:bla.cpp:(.text+0x19f7): undefined reference to `Bla::instance'
I'm using GCC 4.4.0 from the Qt SDK.
I can't figure it out what I'm doing wron开发者_StackOverflow中文版g. Can someone shed a light on this issue?
You missed a Bla
, and instead created a global. Make it:
Bla* Bla::instance = 0;
精彩评论