linker cannot find a C++ static member

This question already has an answer here:

  • What is an undefined reference/unresolved external symbol error and how do I fix it? 27 answers

  • You have declared id as a static variable. You then set it in every constructor call, which is probably not what you want to do.

    For a 'fix', you can add the following line above main:

    int Emp::id = 0;
    

    However, you may not want that to be static. For more information on static class variables, see this page

    链接地址: http://www.djcxy.com/p/86348.html

    上一篇: XCode MAC编译错误

    下一篇: 链接器找不到C ++静态成员