Undefined reference to static constexpr char[]

前端 未结 6 1535
甜味超标
甜味超标 2020-11-22 08:06

I want to have a static const char array in my class. GCC complained and told me I should use constexpr, although now it\'s telling me

6条回答
  •  醉酒成梦
    2020-11-22 08:52

    Add to your cpp file:

    constexpr char foo::baz[];
    

    Reason: You have to provide the definition of the static member as well as the declaration. The declaration and the initializer go inside the class definition, but the member definition has to be separate.

提交回复
热议问题