According to this
pointer is not stored as part of the array itself (or anywhere else in memory) when an array
decays to pointer.
If the above statement is true,how can the data type of &array be different than array or &array[0] but all three have the same value in the following declaration.
int array[10];
I thought when the compiler silently decays an array to pointer, it should give the pointer some memory address. if it’s not, then where does the pointer get stored?
Thanks in advance.
when you use address-of operator on expression
array, expressionarraydoesn’t decays in to pointer (same when you usesizeof, when you usetypeid, and when you pass an array as an argument where the formal argument is a reference to array). In other expressions it generally decays to pointer to its first element.given the declaration
the type of
&arrayisint (*const)[10]where as type of&array[0]isint *const== type ofarrayin an expression where it decays.