下面3段程序代码的效果一样吗?
下面3段程序代码的效果一样吗?
|
1
2
3
4
|
int b;(1)const int *a = &b;(2)int const *a = &b;(3)int *const a = &b; |
正确答案: C 你的答案: C (正确)
(2)=(3)
(1)=(3)
(1)=(2)
都不一样
都一样
tips:const在*的左边,则指针指向的变量的值不可直接通过指针改变(可以通过其他途径改变);在*的右边,则指针的指向不可变。简记为"左定值,右定向"。
Jumping from failure to failure with undiminished enthusiasm is the big secret to success.

浙公网安备 33010602011771号