You don't really need to have an array to store bricks. Once you create and add a brick to the window, it stays there until you remove it using the function named removeGObjectremoveGWindow()
from the SPL library passing to it a reference to that brick after you get that reference returned by detectCollisio()
.
I guess the error you're getting is because you're declaring the array and specifying its size with a variable that's not guaranteed to be initialized though.