Confusion regarding pointers to pointers
arrays, c++, new-operator, pointers
Solution
What does the below statement actually mean
It means an array of pointer to pointer to `int`. There are exactly 10 elements in the array, and each element has a type of `int**`.
What does the below statement depict?
It first accesses the first element in the array and then dereferences it to access the `int*`. The int pointer pointed to by the first element is assigned to point at the newly allocated memory. The newly allocated memory holds a value of `5`.
And is the first statement equivalent to int* (*arr)[10];
No, not at all. `int* (*arr)[10];` is a pointer to an array of `int*`. In other words it isn't an array, it is a pointer to an array, and the array that it points to contains 10 elements which are all `int*`.
Problem
I am a bit confused about pointers to pointers and wasn't able to find desired results due to Google omitting out some symbols. What does the below statement actually mean ``` int** arr[10]; ``` Is it an array of 10 double pointers or is it pointer to array of 10 integer pointers(or both the statements are same). What does the below statement depict? ``` *arr[0] = new int(5); //assign the first pointer to array of 10 pointers a memory of 5? ``` And is the first statement equivalent to ``` int* (*arr)[10]; ``` It would be appreciated if someone clears my doubts. Thanks!