开发者

Undefined reference to static member

开发者 https://www.devze.com 2023-01-18 03:43 出处:网络
I have a static member in my class. It\'s declared and defined: In my header: class Bla { ... static Bla* instance;

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消