c++ - Why is it a compile error to assign the address of an array to a pointer "my_pointer = &my_array"? -
int my_array[5] = {0}; int *my_pointer = 0; my_pointer = &my_array // compiler error my_pointer = my_array // ok
if my_array
address of array &my_array
gives me?
my_array
name of array of 5 integers. compiler happily convert pointer single integer.
&my_array
pointer array of 5 integers. compiler not treat array of integers single integer, refuses make conversion.
Comments
Post a Comment