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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -