<分区>
Possible Duplicate: What is the difference between const int*, const int * const, and int const *?
以下有什么区别?
char const *p;
const char *p;
char *const p;
有没有我可以重新学习 C 和 C++ 的好网站?好像我忘了它,工作面试让我很难受......
<分区>
Possible Duplicate: What is the difference between const int*, const int * const, and int const *?
以下有什么区别?
char const *p;
const char *p;
char *const p;
有没有我可以重新学习 C 和 C++ 的好网站?好像我忘了它,工作面试让我很难受......
最佳答案
前两个是一样的。
诀窍是,倒着读....
所以第一个是:
backwards: p * const char read: p is a pointer to a const char meaning: you can change p to point a at something else, but you can't change what it points at
最后一个是:
backwards: p const * char read: p is a const pointer to a char meaning: p is a pointer which you can't change what it points at, but you can change the thing it points to.
关于c - C中各种const声明的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2900467/