C++ static data members initialization

前端 未结 2 688
南笙
南笙 2021-01-27 03:58

1) Is it true that static data members of classes always get initialized before main() called?

2) Is it true that \"static initialization order fiasco\" can happen if st

2条回答
  •  一个人的身影
    2021-01-27 04:46

    1) Is it true that static data members of classes always get initialized before main() called?

    yes they would always be initialized before program starts executing.

    2) Is it true that "static initialization order fiasco" can happen if static data member of class initialization code uses global static variable of other translation unit?

    Yes, along with this it also happens for every other thing which is initialized before main() execution.

提交回复
热议问题