vendredi 14 décembre 2018

C++11 Undefined Reference to constexpr char[]

I got a templated class CFoo. I'd like to Access a constexpr string (I don't care if it's a string or char []) But I allways got undefined reference when compiling.

template<class T>
class CGlobal_Struct
{
public: void Foo_Func()
{
//do something with error_string
}
private:
static constexpr char error_string[] = "Foo";
}

Normaly I'd put the initialisation of error string I a c file. But because of the template this is not possible. Is there any way arround this Problem? I'd really like to avoid a #define

Normaly i'd put initialisation of error string i a c file. But because of the template this is not possible. Is there any way arround this Problem? I'd really like to avoid a #define

Aucun commentaire:

Enregistrer un commentaire