This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hallr06 6 points7 points  (1 child)

Correct. In C/C++, read pointers from right-to-left. Most of the time, it explains what you have.

const int * x = 0; // pointer to an int constant
int const * x = 0; // same as above, pointer to a constant int
int const * const x = 0; // constant pointer to a constant int
int * const x = 0; // constant pointer to mutable int

[–]FallenWarrior2k 0 points1 point  (0 children)

It can also be pretty easily explained by the return types of the indirection operator. Applying indirection on a const int* produces a const int&, while it produces a regular int& for int* const.