Debouncing array buttons

Hello guys,

as I was currently adding a 4x4 keypad to my very first sequencer,
I got myself into some trouble with keypad buttons and the way to debounce them efficiently.

The code I am trying to use is this one, where the indexes of "button" match indexes of "played" :

for (short i=0;i<4;i++){
          for (short j = 0;j<4;j++){
              if (button[i][j].update()){   // error in request for member "update";
                    if (played[i][j]== 1)         //the array "played" records sequences which have to be played.
                          played[i][j] = 0;
                 else
                          played[i][j] = 1;
              }
          }
    }

And this is the way I tried to create it.
There are several problems which are:
It seems I can't use indexes when creating Bounce objects, because gcc tells me they could be uninitialized.
I need to create the Bounce objects outside of the setup function but it seems that this isn't legit to use incrementation there.

char button[4][4] = {
  {'0','1','2','3'},
  {'4','5','6','7'},
  {'8','9','A','B'},
  {'C','D','E','F'}
};

for (short i=0; i<4; i++){
    for (short j=0; j<4; j++){
        Bounce button[i][j] = Bounce();
        button[i][j].attach(array[i][j]);   //array is filled with input pins
        button.interval(5);
    }
}

I saw there was a keypad library but this isn't that much useful if I got it right,
because I would have to write something like this:

pressed = Keypad.getKey();
if (pressed == '0')
    played[0][0] = 1;
if (pressed == '1')
    played[0][1] = 1;
//etc...

So, I am pretty stucked and don't know how to go where I want,
any help guys ?

Thank you !

for (short i=0; i<4; i++){
    for (short j=0; j<4; j++){
        Bounce button[i][j] = Bounce();
        button[i][j].attach(array[i][j]);   //array is filled with input pins
        button.interval(5);
    }
}

Creating an array of buttons that is local to the inner loop seems pointless. The Bounce constructor should never be called directly. Even if it could be, it doesn't return an array of instances.

You can declare a global (not local) array of Bounce objects.

Bounce bounces[4][4];

You can attach those objects to pins, using nested for loops as you are doing here. But, you do NOT call the constructor or declare an array in the inner loop.

for (short i=0;i<4;i++)
{
    for (short j = 0;j<4;j++)
    {
        bounces[i][j].attach(array[i][j]);
    }
}

That worked indeed, thank you for replying that fast!