Q我已经有了声明
typedef char *charp; const charp p;为什么p变成const,而不是它指向的字符?
A typedef替换不是纯文本的。(这是typedefs 的优点之一;请参见问题 1.13。) 在声明中
const charp p;p是const与相同的原因const int i声明i为const。该typedef“已声明”的声明p不会“查看”内部的typedef以了解其中涉及指针。
其他链接:进一步阅读
参考:H&S 第 4.4.4 节 pp. 81-2