关于const int *p与 int *const p的区别
来源:互联网 发布:释行宇谭腿 知乎 编辑:程序博客网 时间:2024/05/17 08:16
简单来说就是:
const int *p 不可以通过使用p来改变 p所指向变量的值。
例如:
int a = 1;
const int *p = &a;
(*p)++;//不可以
p++;//可以
这样的做法是错的。不可用p改变a的值,但是p的值(p所指向的地址)是可以改变的
int *const p不可以改变p的值,可以改变p所指向变量的值
例如:
int a = 1;
int *const p = &a;
(*p)++;//可以
p++;//不可以
不可以改变p的值(p所指向的地址),但是p所指向变量的值是可以改变的。
0 0
- 关于const int *p与 int *const p的区别
- const int *p与int *const p的区别
- const int *p与int *const p的区别
- const int *p与int * const p的区别
- const int* p与int *const p的区别
- const int *p与int *const p的区别
- const int *p与int *const p的区别
- const int *p与int *const p的区别
- const int *p与int *const p的区别
- int * const p 与int const *p或者const int *p的区别
- const int *p,int *const p区别
- const int *p,int *const p区别
- const int *p,int *const p区别
- int * const p 与 const int *p
- int *const p 与 const int *p
- const int *p与int *const p
- int const *p与int *const p区别
- const指针,const int * p, int *const p,int const * p的区别
- MAC 下面MySQL的字符集修改
- python3.6更新bs4
- CCF修地铁
- 算法设计作业7
- 四款linux操作系统总有一款适合你
- 关于const int *p与 int *const p的区别
- spring3+mybatis3整合报错
- MyBatis--查询缓存--内置二级缓存的使用原则
- 谈谈程序员的焦虑感
- Hadoop 性能优化
- sprintf 字符串格式化
- 剑指offer--跳台阶
- UVA 147 Dollars ( 完全背包+求解方案数精度问题)
- 【Linux】让Ubuntu 支持 GBK等字符集,解决中文乱码