The const keyword can be placed at different places.
Code:const int *ptr3 = 0; int const *ptr4 = 0;What`s the difference?Code:const int a = 5; //can not be changed int const b = 6;//can also not be changed
The const keyword can be placed at different places.
Code:const int *ptr3 = 0; int const *ptr4 = 0;What`s the difference?Code:const int a = 5; //can not be changed int const b = 6;//can also not be changed
In this case, your preference is the only difference.
If you would want a const pointer to int instead of a pointer to const int, placement does matter.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
The only time it matters is with pointers.
If the const comes before the * as in: const char* string; then that means the string cannot be changed, but the pointer can be changed.
If the const comes after the * as in: char* const string; then that means the pointer to string cannot be changed, but the string itself can be changed.