c++ - When do I use & when making a pointer -
this question has answer here:
- what array decaying? 7 answers
i understand this:
int foo = 5; int * foopointer = &foo;
but know can this:
int foo[5] = {32,12,4}; int * fooptr = food;
which strange because when int
have put &
operator before foo
, don't have if array. can declare pointer , array?
it's not list; it's array.
under circumstances, name of array evaluates address of first element of array, can assign (or use initialize) pointer element type of array.
there few exceptions (passing array sizeof
or address-of operator (unary &
), or passing array reference, none of applies here.
Comments
Post a Comment