I fail to understand is why does the code print '3' in VS2010 (release build), whether I leave the declaration of 'r' or comment it out.
int main(){
int arr1[2];
int &r = arr1[0];
int arr2[2];
cout << (&arr1[1] - &arr2[0]);
}
So, three questions:
a. why does the code print 3?
b. why does it print 3 even if the declaration of 'r' is present? (Is it because that in C++ whether a reference occupies storage or not is implementation defined?)
c. Does this code have undefined behavior or implementation defined behavior?