Undefined Reference to class static member in static member

后端 未结 1 348
太阳男子
太阳男子 2021-01-17 05:19

I am creating a linked list with self referential class in C++ and I want to have a static pointer of the type Item (Item is the class name) named \"startPointer\" so that w

相关标签:
1条回答
  • 2021-01-17 05:36

    You have to define your static member like this:

    Item* Item::startPointer = nullptr; // or = NULL; if your cpp version is below c++11
    

    Write such a line in a single compilation unit (cpp file), otherwise the member is just declared.

    0 讨论(0)
提交回复
热议问题