I have learned (correct me if I am wrong) much about the keyword const
and I learned that it is very easy if you read it from the right to the left like this:
int a = 0; // `a` is an integer. Its value is initialized with zero
const int b = 0; // `b` is an integer which is constant. Its value is set to zero
int * c = &a; // `c` is a pointer to an int. `c` is pointing to `a`.
int * const d= &a; // `d` is a constant pointer to an int. It is pointing to `a`.
const int * e = &a; // `e` is a pointer to an int which is constant. It is pointing to `a`.
int * const f = &a; // `f` is a constant pointer to an int. It is pointing to `a`.
const int * const g = &b; // `g` is a constant pointer to a constant integer. It is pointing to `b`.
But what is about this:
int const * h;
Is h
a pointer to a constant int? If yes, what is the different to e
?
And what is about this:
int const i;
Is i
this the same type as b
?