0
Does int a[]{}; is a empty array?
5 Answers
+ 20
if you mean
int a[]={};
answer is yes
+ 4
int a[]{};
initializes an array a of size 0 storing no elements.
Note that this is list initialization, which is a valid syntax for for initializing arrays, e.g.
int arr[] = {1,2,3};
int arr2[]{1,2,3};
http://en.cppreference.com/w/cpp/language/list_initialization#Explanation
+ 4
Martin Taylor Ah, thanks. I've just read an article on how list initialization may be useful, though. Turns out it might not just be a shorthand, but I may be wrong. Of course, conflicting views are also present. Thoughts?
https://stackoverflow.com/questions/18222926/why-is-list-initialization-using-curly-braces-better-than-the-alternatives
+ 1
The array needs to be declared first.
Try:
int [] a = new int[10];
This array will be declared as an array capable of storing up to 10 elements.