×

Loading...

maybe so late. but i also want to know if it's right.

const int * x means "x" is a pointer which point to a int variable, and the variable is constant.

int const* x is the same meaning as above.

The key is the syntax is: "const" always combine with the left word, forever. (so we can say in instance 2, the "const" modify the "int");
But there is a exception: when the word is a simple type such as "int", "float"( not complex like class type), the "const" can be put to the right of the word such as "const int", just like the instance 1.

so this exception make the confuse. In fact it's the same.
Report

Replies, comments and Discussions: