I have seen lots of people asking difference between const pointer and a pointer pointing to a const object.
C++ is lots funny and it so happened that I recently had to come across these feature in my work . for a moment even I was confused , but only when I went to the basic principles ,thing s got set right.
Ok ,so here is a snippet which should clear your doubt.
char const *p1 = "A";
char *const p2= "B";
const char const *p3="C";
//consider the below operation ;
*p2 =”C” ; //Allowed
p2 = “D” ; //Not Allowed
*p1= “C” //Not Allowed
p1= “D” //Allowed
*p3=”C”; //Not allowed
p3=”D” ; //Not allowed
PS: const char * and char const * are same because C++ standard suggest that you can put const keyboard in front of a
type or variable.
Though funny that’s how it works 🙂
For more info see below links