c++ - How to create a static constant member std::string array? -
i cannot believe sounds simple can hard.
class outputhandler { private: static std::string const errorprefixes[] = {"info", "warning", "error", "crash"}; };
how do properly? various documentations understand cannot initialize static member objects, regardless of them being constant.
write initialization outside class, definition:
class outputhandler { private: static std::string const errorprefixes[]; }; std::string const outputhandler::errorprefixes[] = {"info", "warning", "error", "crash"};
(the definition of course subject one-definition-rule , must appear in 1 single translation unit, e.g. outputhandler.cpp
.)
Comments
Post a Comment