Is this a valid definition of a 2D array in C ++?

I just saw something like this in C ++ code (which compiles and probably works in VS2010):

int *p = new int[8, 6];
p[2, 3] = 5;

Is this a new notation for creating multidimensional arrays in C ++? Or am I missing something? As far as I remember, arrays are declared this way [a] [b] not [a, b] in C ++. It would be very helpful if you could explain this code.

Thank.

+5
source share
1 answer

This is a valid syntax, but it does not define 2D arrays. It uses a comma , so it is equivalent to:

int *p = new int[6];
p[3] = 5;
+7
source

All Articles