Reputation: 26477
I'm trying to solve the difference between three following declarations in c++. I appended my guesses:
const float *x[4]
- 4-element array of pointers on arrays of constant floatsconst float (*x)[4]
- I'm confused here... is it the same as above?const float *(*x)[4]
- the same as above but "on arrays of arrays of constant floats"Any help/explanation will be appreciated.
Upvotes: 0
Views: 107
Reputation: 3107
Use cdecl
to know declarations,
const float *x[4]
- Declare x as array 4 of pointer to const floatconst float (*x)[4]
- Declare x as pointer to array 4 of const floatconst float *(*x)[4]
- Declare x as pointer to array 4 of pointer to const floatSource : cdecl.org
Upvotes: 4
Reputation: 7610
const float *x[4] - An array of pointers to constant floats
const float (*x)[4] - A pointer to an constant float array with 4 elements
const float *(*x)[4] - A pointer to an array of pointers to constant float
Upvotes: 1
Reputation: 1430
const float *x[4] - 4-element array of pointers on arrays of constant floats
4-element array of pointers to constant floats.
const float (*x)[4] - I'm confused here... is it the same as above?
Pointer to 4-element array of constant floats.
const float *(*x)[4] - the same as above but "on arrays of arrays of constant floats"
Pointer to 4-element array of pointers to constant floats.
Upvotes: 2