📜  c++ ints 是否需要被初始化 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:52.933000             🧑  作者: Mango

代码示例1
tldr; Yes, or you risk getting a random number as the starting value.

For automatic variables:
Some compilers might do it but the standard does not require it. A conforming implementation could leave them to be uninitialized garbage values.

For static variables:
They must be initialized to zero unless explicitly initialized otherwise.