StupidBeauty
Read times:1130Posted at:Fri Apr 18 00:41:38 2014
- no title specified

转载 Undefined reference to static class member

对于类中的静态成员变量,必须在类之外的某处实际定义一下,否则编译时将会“undefined reference to static class member”。

http://stackoverflow.com/questions/272900/undefined-reference-to-static-class-member

亮点:


115
down vote accepted

You need to actually define the static member somewhere (after the class definition). Try this:

class Foo { /* ... */ };

const int Foo::MEMBER;

int main() { /* ... */ }

That should get rid of the undefined reference.

share | improve this answer

edited Jan 4 at 21:37

user529758

answered Nov 7 '08 at 17:57

Drew Hall
15.1k 53552

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4