C++ - value of uninitialized vector

后端 未结 5 1522
情歌与酒
情歌与酒 2020-12-03 09:28

I understand from the answer to this question that values of global/static uninitialized int will be 0. The answer to this one says that for vectors, the default construc

5条回答
  •  清歌不尽
    2020-12-03 10:13

    The zero initialization is specified in the standard as default zero initialization/value initialization for builtin types, primarily to support just this type of case in template use.

    Note that this behavior is different from a local variable such as int x; which leaves the value uninitialized (as in the C language that behavior is inherited from).

提交回复
热议问题