指向常量的指针与常量指针(A pointer to a constant And A constant pointer)
指向常量的指针(A pointer to a constant)
可以改变指针中存储的地址,但不允许使用指针改变她指向的值;
long value = 9999L;
const long *ptrvalue = &value; //Defines a pointer to a constant
*ptrvalue = 8888L; //Error - attempt to change const location
//ptrvalue指向的值不能改变,但可.
原创
2021-08-23 17:56:08 ·
150 阅读 ·
0 评论