array initialisation

后端 未结 3 1267
孤独总比滥情好
孤独总比滥情好 2020-12-18 16:52

I\'m quite certain that arrays of built in types are unitialized, whereas arrays of UDTs are default initialized.

int foo[5]; // will contain junk
Foo foo

3条回答
  •  情话喂你
    2020-12-18 17:44

    "Members of arrays and structures are default initialized or not depending on whether the array or structure is static"

    This is authoritative, although it could be clearer:

    • Arrays and structures declared as static are initialized to zeroes.
    • Local arrays and structures of built-in types (i.e. types that have no constructors) are not initialized.

提交回复
热议问题