Pointers and Constants

本文深入解析指针常量与指针的区别,通过实例与解释帮助理解两者概念,避免混淆。

常量指针与指针常量,非常容易混淆,在网络和各种教程上看了各式各样的对比的记忆技巧,当时可以区分,但过段时间,又搞不清楚了。看到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 代替 *。

转载于:https://my.oschina.net/zengsai/blog/102286

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值