c中const的使用
来源:互联网 发布:java asynchttpclient 编辑:程序博客网 时间:2024/05/20 11:21
const关键字:
int const *p和const int *p的功能一样,都是p指向的对象不能通过p指针改变,p可以变;即*p为常量,不可以改变,而指针p为变量可以更改。
int a=1;int b=2;int const *p1;p1=&a;p=&b; //可行*p1=3; // 不可以
int* const p声明中p不可变,而p指向的对象可以改变,这种指针在定义是必须进行初始化,初始化时指向相应的对象后,就不能更改指向的对象。
int a=1;int b=2;int * const p2=&a;p2=&b; //不可行*p2=3; //可行 a=3
const int *const p声明时 p和p指向的对象均不可变。
0 0
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- C中CONST的使用
- c中const的使用
- C中CONST的使用
- C中CONST的使用
- C中const的使用
- C/C++ 中& * const与 const * 以及volatile的使用
- C语言中const的使用
- C语言中const的使用
- 嵌入式C中const关键字的使用
- C中const 定义常量的使用
- OC入门笔记
- Hibernate 多对一(Many-to-One)映射
- java和Android都是新手,想学Android,怎样入门
- 第十周项目1-程序填充与阅读(三)
- 程序员生存定律--表达背后的力量(1)
- c中const的使用
- Cocoa 框架 For iOS(一) 框架的介绍,Objectivie-C运行时能力的解析等
- C++中值传递、指针传递、引用传递的总结
- 互斥锁和条件变量的结合使用
- 无法Debug SQL: Unable to start T-SQL Debugging. Could not attach to SQL Server process on
- hdu4416 Good Article Good sentence(SAM)
- hdu 5015 233 Matrix (递推 矩阵快速幂)
- Hadoop cdh4.2.1 安装笔记
- websocket