[Cs3] array/vector initialization with an initializer list

Mikhail Nesterenko mikhail at cs.kent.edu
Tue Sep 8 15:01:20 EDT 2015


CS3 students,

This is per in class discussion.

The rule is that if there is no initialization at all, the array
values are unspecified. If there is initialization, whatever elements
are not given initial values, they are assigned a value of
zero. Hence, a straightforward way to assign zero to every element of
the array is this:

   int a[25] = {0};

In fact, even this zero-initializaiton is legal:

   int a[25] = {}; // although a bit unintuitive

Here is more 

   http://www.fredosaurus.com/notes-cpp/arrayptr/array-initialization.html

Thanks,
-- 
Mikhail


More information about the cs3 mailing list