Have you considered using a vector of vectors instead of a 2D array? For example:
You would then be able to access bricks[i][j] as a Brick object instead of a Brick pointer, and you would no longer need to worry about managing the memory for the dynamic array.Code:std::vector<std::vector<Brick> > bricks(bh);
for (int i = 0; i < bh; ++i)
{
bricks[i].reserve(bw);
for (int j = 0; j < bw; ++j)
{
bricks[i].push_back(Brick(
35 * i + 250.0f / 1024.0f * SCREEN_WIDTH,
18 * j + 200.0f / 768.0f * SCREEN_HEIGHT));
}
}