0
SDL_Rect *rect = new SDL_Rect[4][2];

Error says: "Error: 'this' cannot be used in a constant expression." Any help??? Happens on the second dimension of the array.

Greymouth
  • 15
  • 4

2 Answers2

2

If you know the size of the array, just

SDL_Rect rect[4][2];

will do what you want.

If you know all dimensions but the first (or if you really need the matrix to be in the heap), you can do

SDL_Rect (*rect)[2] = new Rect[x][2];
Massa
  • 8,647
  • 2
  • 25
  • 26
0

Have a look at this:

The correct way to initialize a dynamic pointer to a multidimensional array?

Initialization of multidimensional arrays is clearly explained.

Community
  • 1
  • 1
jRobin
  • 11
  • 2