I have struct A
and following code: A *const *ppA
What does this code mean? It is a pointer to a constant array? I'm not sure so I asked this question here
Asked
Active
Viewed 161 times
2

Quest
- 2,764
- 1
- 22
- 44
-
This is a pointer to a const pointer to a struct A http://stackoverflow.com/questions/1143262/what-is-the-difference-between-const-int-const-int-const-int-const – spiritwolfform Mar 03 '14 at 12:47
-
1Where do you get the array from? There's no array in the declaration. (Of course, any pointer _might_ point to the first element of an array. Or not.) – James Kanze Mar 03 '14 at 13:16
-
1@JamesKanze I'm using it as a pointer that point to the first element of an array so that's why :) – Quest Mar 03 '14 at 13:45
1 Answers
7
const
and volatile
qualify the type immediately before them (unless they appear at the beginning, in which case they qualify the type immediately after them); so you can read this from right to left:
ppA
is a (non-constant) pointer to a constant pointer to a (non-constant) A
.
There's no way to tell from the declaration whether it might be used to point to a single object, the first of an array, or no object at all.

Mike Seymour
- 249,747
- 28
- 448
- 644