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
-
This is a pointer to a const pointer to a struct A stackoverflow.com/questions/1143262/…spiritwolfform– spiritwolfform2014-03-03 12:47:25 +00:00Commented Mar 3, 2014 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– James Kanze2014-03-03 13:16:00 +00:00Commented Mar 3, 2014 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– Quest2014-03-03 13:45:56 +00:00Commented Mar 3, 2014 at 13:45
Add a comment
|
1 Answer
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.