- 网上已经有很多人总结了这个内容,但是我感觉对于我的理解来说还是比较难的,于是我今天又去查了资料学习了一遍,希望对于迷惑的小伙伴有学习的帮助哦
conclusion:
- expression of two type of points:
- 常指针
int a=100; int * const p=&a;- 指向常量的指针:
int a=100; const int *p=&a;
- the difference of two points
| 常指针 | 指向常量的指针 |
|---|---|
| 指针里面存放的地址不能改变,但是里面的内容可以改变 | 指针里面的地址可以改变,但是里面的内容不能改变 |
- the follow is the code to validate above contents
#includeusing namespace std; //常指针:指针是一个常量,即你所定义的指针的地址不能改变,但是内容可以改变 //指向常量的指针:指针的地址可以改变,但是指针所指的内容不能改变 int main() { int a = 100; int b = 101; int *const p = &a; //常指针: cout<<*p< Put on steam! 考研人
2022/5/29



