关于const修饰指针
2013-05-06 15:20
99 查看
在《C语言深度解剖》一书里P32页
const int *p;
int const *p;
int * const p;
const int * const p;
在确定const的修饰对象时,书中给出的技巧很实用,如下,剔除数据类型名,const离谁近就修饰谁。
const int *p;
//const修饰*p,p可变,p指向的对象不可变;
int const *p;
//同上;
int * const p;
//const修饰p,p不可变,p指向的对象可变;
const int * const p;
//前面的const修饰*p,后面的const修饰p,都不可变
const int *p;
int const *p;
int * const p;
const int * const p;
在确定const的修饰对象时,书中给出的技巧很实用,如下,剔除数据类型名,const离谁近就修饰谁。
const int *p;
//const修饰*p,p可变,p指向的对象不可变;
int const *p;
//同上;
int * const p;
//const修饰p,p不可变,p指向的对象可变;
const int * const p;
//前面的const修饰*p,后面的const修饰p,都不可变
相关文章推荐
- 程序员面试(3):关于const修饰指针的情况
- 关于const修饰指针
- 关于const修饰指针的情况
- 关于const修饰指针
- 关于const 修饰变量、引用、指针的说明
- 关于const修饰指针的问题
- 关于const与指针
- const修饰指针和引用的用法
- 【C++】关于带const的指针问题
- const修饰指针和引用的用法
- C++中const修饰基本数据类型、指针、引用、对象
- const修饰的指针的用法解析
- 关于多重间接运算指针的const问题
- const和#define的不同以及 const修饰指针的几种情况
- 关于const限定的字符指针
- 关于const和指针的专题
- const修饰指针和引用的用法【转贴】
- C语言--const修饰指针解析
- const修饰指针的情况分析
- [c/c++]const修饰指针