A const pointer is a pointer which can’t be reassigned to another address once it is initialized.
We can create const pointer as follows:
int value{100};
int* const cptr{&value};Using const after * creates a const pointer (unlike pointer to const where we use const before the type).
We can change the value of value variable using pointer dereferencing as it is pointing to a non-const value.
*cptr = 200; // it will work as const pointer is pointing non-constHowever, we can’t reassign this pointer to point another object.
int anothervalue{1};
cptr = &anothervalue; // it will fail.