C语言CONST
来源:互联网 发布:剑三御姐捏脸数据 编辑:程序博客网 时间:2024/05/16 05:22
关于CONST的学习:
主要分为两点:
1.const的修饰的格式:
const使用的基本形式: const type m;限定m不可变。当然m可以使指针或者其他的类型
看一下代码的例子:
int const n1 = 19;int const n2 = 29;//这个情况不可以修改指针指向的值:*p1 = 1;这个就是错误int const *p1,*p2 ;p1 = &n1;p2 = &n2;p1 = p2;//*p1 = 1;//这个情况不可以修改指针指向的值:*p3 = 33;这个就是错误const int *p3;p3 = &n1;p3 = &n2;
细化说明:
const int nValue; //nValue是const
const char *pContent; //*pContent是const, pContent可变 const char* const pContent; //pContent和*pContent都是const其中注意的是 const修饰在前面和后面都是一样的效果哈。。。。
2.const出现的一行语句中出现的多种情况:
1)
int const * p1,p2; p2是const;(*p1)是const.2)
int const * const p1,p2;
3)
int * const p1,p2;
关于CONST的学习:
主要分为两点:
1.const的修饰的格式:
const使用的基本形式: const type m;限定m不可变。当然m可以使指针或者其他的类型
看一下代码的例子:
int const n1 = 19;int const n2 = 29;//这个情况不可以修改指针指向的值:*p1 = 1;这个就是错误int const *p1,*p2 ;p1 = &n1;p2 = &n2;p1 = p2;//*p1 = 1;//这个情况不可以修改指针指向的值:*p3 = 33;这个就是错误const int *p3;p3 = &n1;p3 = &n2;
细化说明:
const int nValue; //nValue是const
const char *pContent; //*pContent是const, pContent可变 const char* const pContent; //pContent和*pContent都是const其中注意的是 const修饰在前面和后面都是一样的效果哈。。。。
2.const出现的一行语句中出现的多种情况:
1)
int const * p1,p2; p2是const;(*p1)是const.2)
int const * const p1,p2;
3)
int * const p1,p2;
- 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语言----------const关键字
- C语言const
- C语言关键字const
- C语言const
- C语言中的const
- ubuntu12.04改名
- Design Pattern :Simple Factory
- Java死锁参考
- oracle with as 语法
- javascript常用的107个语句
- C语言CONST
- poj2370-看题目的时间比写代码AC的时间都长,水题为啥都那么难理解呢,可能英文太差了?
- Linux下搭建SVN服务器
- BPM Console Reference(jbpm5学习资料)
- [原创]wordpress设置全局字体|标题字体|内容字体|图文教程
- 关于进程
- 排序系列之二分插入法
- UbuntuServer搭建Git服务器之gitdeamon和gitweb(四)
- Bugzilla相关的东西