Wednesday, September 15, 2010

Initializing a Static Variable at Compile Time

For a static variable to be initialized at compile time, it needs to be initialized by a compile-time constant, and cannot have a constructor; Otherwise, it is initialized at runtime.

Reference: Modern C++ Design: Generic Programming and Design Patterns Applied by Andrei Alexandrescu. Addison-Wesley, 2001, p. 133-134.

No comments:

Post a Comment