The const keyword in C++ provides a type-safe way to replace some of those #define preprocessor statements that you’re used to writing from C.Whenever you have a value that you do not wish to have changed, you should declare it as const. For example:
const int i = 12; // any further attempt to alter i will cause an error.
However, when pointers are involved, what is actually constant depends on where you place the const keyword. Also, the syntax can be slightly confusing.
- Pointer to a constant: A pointer to a constant is just that