Pointers and Constants

原创
2013/01/15 14:58
阅读数 92

常量指针与指针常量,非常容易混淆,在网络和各种教程上看了各式各样的对比的记忆技巧,当时可以区分,但过段时间,又搞不清楚了。看到C++作者的一句描述后,“啪”一下,就记住了,也许这辈子都不会忘记了,除非得了老年痴呆~~呵呵,与大家分享一下:

When using a pointer, two objects are involved: the pointer itself and the object pointed to. “Prefixing” a declaration of a pointer with const makes the object, but not the pointer, a constant. To declare a pointer itself, rather than the object pointed to, to be a constant, we use the declarator operator *const instead of plain *.
定义指针常量时,我们使用 *const 代替 *。

展开阅读全文
加载中
点击加入讨论🔥(2) 发布并加入讨论🔥
2 评论
0 收藏
0
分享
返回顶部
顶部