A T * can be implicitly converted to a const T *
《C++程序设计语言》里的,《C++标准》应该也找的到。
编译会出错,const放在这有很大的烟雾作用。
知道看到了这么一句话:
const int **ppc;
ppc : a pointer to a pointer to a constant integer.
这下就了解了:
在上段代码里p转换成char **类型,T为char *,所以可隐式转换的类型为char *const*
让人又爱又恨的指针
本文深入探讨了C++中指针的用法及其隐式转换特性。通过具体示例解释了如何理解指针的多重含义,并揭示了常量指针在实际应用中的陷阱。
843

被折叠的 条评论
为什么被折叠?



