to understand this you need to understand the difference between
1. pointer to constant
2. constant pointer.
1. pointer to constant
int n1 = 10;
int* pn = &n1;
suppose the address of
n1 is 0x1001.
when we say
pn, it is equal to 0x1001. when we say,
*pn it is equal to 10;
see the below
int n1 = 10;
const int* pn = &n1;
this is a pointer to a constant integer.
means the pointer is not constant. but to what it points to is a constant;
*pn = 10;
int n2 = 20;
pn = &n2;
2. constant pointer
is the other way round of above
int n1 = 10;
int* const pn = &n1;
*pn = 10;
int n2 = 20;
pn = &n2;
keeping all the above in mind we can say
const char* const authoeName = "Scott Meyers" /* is a constant pointer to a constant character. both the pointer and what it points to is constant.*/
const char* const authoeName = "Scott Meyers";
char* bookname = "Effective c++";
authoeName = bookname;
*authoeName = *bookname;
both kind of alteration will cause an error