Paragraph 17 of [dcl.init] specifies all possible initializers for arrays.
17The semantics of initializers are as follows. The destination type is the type of the object or reference being initialized and the source type is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined.
(17.1)If the initializer is a (non-parenthesized) braced-init-list or is = braced-init-list, the object or reference is list-initialized.
(17.2)If the destination type is a reference type, see [dcl.init.ref].
(17.3)If the destination type is an array of characters, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string literal, see [dcl.init.string].
(17.4)If the initializer is (), the object is value-initialized.
(17.5)Otherwise, if the destination type is an array, the program is ill-formed.
(17.2) is not applicable to arrays, so the options are:
- Default-initialization ([dcl.init]/12):
int x[3]; - Value-initialization ([dcl.init]/17.4):
int* x = new int[3](); - List-initialization ([dcl.init]/17.1):
int x[] = {1, 2, 3};orint x[] {1, 2, 3}; - Initialization with a string literal ([dcl.init]/17.3):
char x[] = "text";
Paragraph 17 of [dcl.init] specifies all possible initializers for arrays.
17The semantics of initializers are as follows. The destination type is the type of the object or reference being initialized and the source type is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined.
(17.1)If the initializer is a (non-parenthesized) braced-init-list or is = braced-init-list, the object or reference is list-initialized.
(17.2)If the destination type is a reference type, see [dcl.init.ref].
(17.3)If the destination type is an array of characters, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string literal, see [dcl.init.string].
(17.4)If the initializer is (), the object is value-initialized.
(17.5)Otherwise, if the destination type is an array, the program is ill-formed.
(17.2) is not applicable to arrays, so the options are:
- Default-initialization ([dcl.init]/12):
int x[3]; - Value-initialization ([dcl.init]/17.4):
int* x = new int[3](); - List-initialization ([dcl.init]/17.1):
int x[] = {1, 2, 3};orint x[] {1, 2, 3}; - Initialization with a string literal ([dcl.init]/17.3):
char x[] = "text";
Paragraph 17 of [dcl.init] specifies all possible initializers for arrays.
17The semantics of initializers are as follows. The destination type is the type of the object or reference being initialized and the source type is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined.
(17.1)If the initializer is a (non-parenthesized) braced-init-list or is = braced-init-list, the object or reference is list-initialized.
(17.2)If the destination type is a reference type, see [dcl.init.ref].
(17.3)If the destination type is an array of characters, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string literal, see [dcl.init.string].
(17.4)If the initializer is (), the object is value-initialized.
(17.5)Otherwise, if the destination type is an array, the program is ill-formed.
(17.2) is not applicable to arrays, so the options are:
- Default-initialization ([dcl.init]/12):
int x[3]; - Value-initialization ([dcl.init]/17.4):
int* x = new int[3](); - List-initialization ([dcl.init]/17.1):
int x[] = {1, 2, 3};orint x[] {1, 2, 3}; - Initialization with a string literal ([dcl.init]/17.3):
char x[] = "text";
Paragraph 17 of [dcl.init] specifies all possible initializers for arrays.
17The semantics of initializers are as follows. The destination type is the type of the object or reference being initialized and the source type is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined.
(17.1)If the initializer is a (non-parenthesized) braced-init-list or is = braced-init-list, the object or reference is list-initialized.
(17.2)If the destination type is a reference type, see [dcl.init.ref].
(17.3)If the destination type is an array of characters, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string literal, see [dcl.init.string].
(17.4)If the initializer is (), the object is value-initialized.
(17.5)Otherwise, if the destination type is an array, the program is ill-formed.
(17.2) is not applicable to arrays, so the options are:
- Default-initialization ([dcl.init]/12):
int x[3]; - Value-initialization ([dcl.init]/17.4):
int* x = new int[3](); - List-initialization ([dcl.init]/17.1):
int x[] = {1, 2, 3};orint x[] {1, 2, 3}; - Initialization with a string literal ([dcl.init]/17.3):
char x[] = "text";