Quest
Quest

Reputation: 2843

Pointer to a constant array

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

Upvotes: 2

Views: 177

Answers (1)

Mike Seymour
Mike Seymour

Reputation: 254741

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.

Upvotes: 7

Related Questions