Someone may be asked at a C++ interview: “What is a static constructor?“.
Possible, one interviewer would expect answers like “A static constructor is one called only once” and/or “A static constructor is called before any other instance”, and so on.
Probably, such guy is a little bit confused by another language background (e.g. C# or C++/CLI), or is one learning some concepts and patterns by heart, or is influenced by some misleading articles found over the Internet.
The right answer is neat and clear: “There is no static constructor in standard C++ programming language“.
Not mentioning other arguments, let’s just quote from the C++ standard:
4. A constructor shall not be virtual (10.3) or static (9.4).
Still don’t believe that? No problem, even just for fun, try compile next code using any C++ compiler:
static CFoo(); // Error: 'CFoo::CFoo()' cannot be declared static
Concluding, just have a look then may forget these links if you are a C++ programmer…
- C# Programming Guide: Static Constructors
- Managed Extensions for C++ Programming: Static Class Constructors
…but don’t forget that neither C#, nor C++/CLI is (standard) C++!