What is a static constructor?

后端 未结 13 1876
天涯浪人
天涯浪人 2020-11-27 03:46

This question was asked to me in an interview:

What is a static constructor?

Does it exist in C++? If yes, please explain it wit

13条回答
  •  盖世英雄少女心
    2020-11-27 04:03

    In C++, there is no static constructor. In C# (and probably in Java too), you can define static constructor which is called automatically by the runtime so as to initialize static members.

    For further question and interest you can read this topic:

    What is the rationale for not having static constructor in C++?

提交回复
热议问题