Static const string won't get initialized

后端 未结 6 1644
一生所求
一生所求 2021-01-13 21:00

I have some static const strings as private members of my C++ class. I am aware of the declaration in .h and definition (and initialization) in .cpp practice. In the class c

6条回答
  •  隐瞒了意图╮
    2021-01-13 21:40

    Based on current code I'd guess you try to create global Test instance, most probably in a different .cpp file. Seems like you are hitting the dreadful static initialization order fiasco. Simply put: the global/static-member variables in a .cpp file will be initialized in the order they are defined. No guarantees are made about global variables in different .cpp files, you cannot rely on var in one file being initialized before or after global variable in another.

提交回复
热议问题