Dear members,
Am learning C++ by Yashawant Kanetkar from his book "Let us C++", its been said his books are good for beginners who do self study like me, but I find some conflict of logic in this book, please help me clear those...
The book says......the following code fragment would help fix ideas about const further
char *p = "Hello" ; //pointer is variable , as well string is <<< I find this wrong
*p = 'M' ; // error
p = "Bye"; //works
const char *q = "Hello"; //pointer is variable, string is constant <<<<I agree, pls confirm if its right
*q = 'M' ; // error
q = "Bye" ; //works
char const *s = "Hello" ; //pointer is variable, string is constant <<<I agree, pls confirm if its right
*s = 'M' ; // error
s = "Bye" ; // works
char * const t = "Hello"; //pointer is constant, so is string<<<<I find this wrong
*t = 'M' ; //works
t= "Bye" ; //error
const char * const u = "Hello"; //string is fixed, so is pointer <<< I agree, pls confirm..
*u = 'M' ; // error
u ="Bye" ; // error