重温 const 指针
来源:互联网 发布:好的视频剪辑软件 编辑:程序博客网 时间:2024/05/22 05:14
在进行声明指针时,可以在类型前或后使用关键字const,也可在两个位置都使用。 下面都是合法的声明,但是含义大不同:
const int * pOne; //指向整形常量 的指针,它指向的值不能修改
int * const pTwo; //指向整形的常量指针 ,它不能在指向别的变量,但指向(变量)的值可以修改。
const int *const pThree; //指向整形常量 的常量指针 。它既不能再指向别的常量,指向的值也不能修改。
理解这些声明的技巧在于,查看关键字const右边来确定什么被声明为常量 ,如果该关键字的右边是类型,则值是常量;如果关键字的右边是指针变量,则指针本身是常量。下面的代码有助于说明这一点:
const int *p1; //the int pointed to is constantint * const p2; // p2 is constant, it can't point to anything else
0 0
- 重温 const 指针
- const 重温
- 【c++学习】重温指针
- CONST 指针
- const指针
- CONST指针
- const 指针
- const指针
- const指针
- const指针
- const指针
- const 指针
- const 指针
- const指针
- const指针
- const指针
- const指针
- const指针
- 六款值得推荐的数据挖掘得力助手
- Eclipse调试常用技巧
- kafka 性能测试
- ls 输出全路径
- Linux下源码安装MySQL
- 重温 const 指针
- [Selenium Web Driver]Click on SVG element
- 用两个栈实现一个队列的功能
- 对Dijkstra算法原理的一些理解
- jquery中的常用事件bind、hover、toggle等示例介绍
- 黑马程序员---description方法(NSLog输出)
- Centos6.4 +Hadoop 1.2.1集群配置
- jsp中kindeditor富文本编辑器的使用
- Android基础之——startActivityForResult启动界面并返回数据,上传头像