c++ static initialization order fiasco
问题 I'm currently learning C++, and I'm having some troubles. I've developped a program by using lots of #define , but I'd like to use static const instead (collision/type/scopes...). So, I now have something like: file1.hpp class A { public: static const std::string MY_CONST_VAR; }; file1.cpp const std::string A::MY_CONST_VAR = "some string"; file2.cpp static std::string arrayOfString[] = { A::MY_CONST_VAR, ... }; My code compiles with no warnings/errors (compiling with -W -Wall -Wextra -Werror