Very simple question

 
int a[100];


Now what will &a return?
Anything?, but its memory address.
Anything? :-D

I guess &a is equivalent to &a[0]
int a[100] ; &a : pointer to the array of 100 int elements.

1
2
3
4
5
6
7
8
9
typedef int array_type[100] ;

array_type array ;
array_type& reference_to_array = array ;
array_type* pointer_to_array = &array ;

array_type array_of_array[20] ;
pointer_to_array = array_of_array ; // points to array_of_array[0]
++pointer_to_array ; // now points to array_of_array[1] 
JLBroges


Then what would be the difference between a and &a ??
closed account (zb0S216C)
Both return the address of the first element. The only visible difference is that "&a" uses an operator to obtain the address.

Wazzak
Last edited on
a is an array; it can be implicitly converted to a pointer to its first element.

&a is a pointer to the array a. *&a is (a refrence to) a.

The type pointer to array is not the same as the the type pointer to the first element of the array.
Last edited on
&a has type int ( * )[100]

a in expressions has type int *
Topic archived. No new replies allowed.