Using Visual Studio Express 2013. I thought I understood static vs dynamic arrays, but the following has me confused:
int* a = new int[3]; \\ dynamic array
int** pa = &a;
int b[3]; \\ static array
int** pb = &b; \\ error: cannot convert from 'int (*)[3]' to 'int **'
Ok, so I try int (*)[3] pb = &b;
but it's not even syntactically correct. The Locals Window says pb is an int[3]
, but int[3]* pb = &b;
is also incorrect.
It also seems strange to me that b
has the same value as pa
. If I replace the declaration int b[3];
with a declaration + initialization int b[3] = {};
then that oddity disappears, so maybe it's just a VS bug:
But I still can't get at the address of the static array. If I type &b
in the Immediate Window then I get exactly the same output as if I just typed b
, which again seems strange by comparison with '&a' and 'a' which are clearly different things: