As you can see in the first example, the minDrinkingAge can be altered to any value you like, making it possible for people of any age able to buy alcohol if they change the value so it is lower or equal to their own age.
To prevent this, the minDrinkingAge is made constant in the second example resulting in a compiler error when any changes are attempted to be made to it's value.
Pointers and "const" together - rules
int i = 5; const int *p = &i;
p is a pointer to an int that is constant
This means that the pointer cannot change the value of the variable it is pointing to, but:
The variable which is points to can change it's own value if it is not declared as a const.
The pointer can change to point to something else.
"const" pointers - rules
int i = 5; int * const p = &i;
p is a constant pointer to an int
Once a pointer is declared and initialised to point to something, it cannot change to point to somewhere else. However:
The constant pointer can change the value of what it is pointing to.
The value of what the constant pointer is pointing to can also change.
References and "const" together - rules
It would be wrong to change a constant variable via a non-constant reference. This means that you cannot bind a non-const reference to a const variable, however:
A const reference can be bound to a non-const variable, but the value of the variable cannot be changed via the reference.
By declaring a variable as "const", indicates that you have no intention of modifying that variable. But this does not mean that others don't have.
"const" applies to whatever is on it's immediate left. If there is nothing, in which case it applies to whatever is on it's immediate right.