Why variable-sized object can be initialized with (), and not with {} in C++

100 Views Asked by At

Why can initialize array nums with parentheses, but cannot with braces? Whats the difference here? I know nums is variable sized object and cannot be initialized, but I am not sure why it can be initialized with zeros using parentheses.

This works:

int n = 5;
int nums[n]();

This doesn't:

int n = 5;
int nums[n]{};
0

There are 0 best solutions below