Can the compiler deal with the initialization order of static variables correctly?
问题 How about the following case? Can the compiler deal with the initialization order of static variables correctly if there is dependency? a.h template<class T> struct A { static double a; }; template<class T> double A<T>::a = 1; b.h struct B { static double b; }; b.cpp #include "b.h" #include "a.h" double B::b = A<int>::a; 回答1: In your example, A<int>::a is initialized statically, and all static initialization takes place before any dynamic initialization. B::b is initialized dynamically and so