Static variable initialization?
I want to know why exactly static variables in C, C++ and Java are initialized by zero by default? And why this is not true for local variables? Paweł Hajdan Why the static variables are deterministically initialized and local variables aren't? See how the static variables are implemented. The memory for them is allocated at link time, and the initial value for them is also provided at link time. There is no runtime overhead. On the other hand, the memory for local variables is allocated at run time. The stack has to grow. You don't know what was there before. If you want, you can clear that