Difference is that arr
is an array, while &arr
is a pointer to the array. Compare to:
#include <iostream>
using namespace std;
int main( )
{
int arr[5] = { 1, 2, 3, 4, 5 } ; // array of 5 integers
int (&ref_arr)[5] = arr; // reference to array of 5 integers
int (*ptr_arr)[5] = &arr; // pointer to array of 5 integers
cout << "array size " << sizeof(arr) << " = " << sizeof(ref_arr) << endl;
cout << "pointer size " << sizeof(&arr) << " = " << sizeof(ptr_arr) << endl;
return 0 ;
}
Possible output (for implementations with 32b integers and 64b pointers):
array size 20 = 20
pointer size 8 = 8