Let's say I declare and initialize the following multi-dimensional array in C++:
unsigned a[3][4] = {
{12, 6, 3, 2},
{9, 13, 7, 0},
{7, 4, 8, 5}
};
After which I execute this code:
cout << a << endl; // output: 0x7fff5afc5bc0
cout << a + 1 << endl; // output: 0x7fff5f0afbd0
cout << *a << endl; // output: 0x7fff5afc5bc0
cout << *a + 1 << endl; // output: 0x7fff5f0afbc4
I just don't understand what is happening here.
ais the address of the first element, right? In single-dimensional arrays,*ashould be the value of the first element, but instead it's the same asa?! What does*aeven mean in this context?Why is
a + 1different from*a + 1?
*(*a + 1)and**(a+1)and you'll see where each point.