I have the following code:
int main()
{
int A[2][2][2] =
{
{{1, 2}, {3, 4}},
{{4, 5}, {5, 6}}
};
cout << A << endl; // assume it's 400
cout << *A << endl; // 400
cout << **A << endl; // 400
cout << ***A << endl; // 1
cout << &A[0][1] << endl; // 408
}
So an array obviously shares a lot of attributes with a pointer - correct me if I'm wrong but in this case, A is a pointer to a 2-dim Array of integers which points at a fictional address 400. So if I dereference once I get a pointer to a 1-dim array of size 2 still pointing at address 400.
My first question is the following: Working with "regular" pointers, dereferencing gives the value stored at the address pointed to. That's not the case for multi-dimensional arrays, right? Because the value stored at address 400 is obviously 1, not 400 (what I think could at least somehow be assumed looking at A and *A).
The second question is about the last cout in the code block. If I would type in A[0][1] I get a "pointer-to-integer type thing", right? So dereferencing once more would give me value 3 at fictional address 408. What if I reference this pointer-to-integer as I did? I know it just gives the address of the first value of the (second) 1-dim array which it is pointing to (so 408), but how do I interpret this? In memory location 408, there's obviously an integer stored (namely 3). But again, only looking at the expression &A[0][1] giving the address 408 one could think that location 408 stores a pointer to integer type thing.
I know these questions may be a bit confusing and even unspecific, but maybe someone has some words which help me with this.
Thanks! :-)