1

In c++, if you do something like:

int array [2][4] = 
{
    {1,2,3},
    {4,5,6,7}
}

Is array [0][3] null or nonexistent?

Matthew D. Scholefield
  • 2,977
  • 3
  • 31
  • 42
  • 1
    If the `{}` initializer is smaller than the array is defined as, the leftover values are zero initialized. – BWG Feb 21 '15 at 19:53

1 Answers1

4

It is actually value initialized, so it will be 0. It is similar to if you had

int values[5] = {1,2};

This would produce the array

{1, 2, 0, 0, 0}

Here is a thorough description of zero-, default-, and value-initialization if you're interested in the definitions and when each applies.

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218