const 用法
来源:互联网 发布:ie9 解析json乱码 编辑:程序博客网 时间:2024/04/27 23:48
C++中将const作为定义常量的标识符,一旦定义为const类型后该数据就为常量不能被修改。注意在定义时必须要对其进行初始化。类中常量只能在构造函数的初始化列表中初始化。
int a(100);
const int b(200);//定义一个int型的常量
int *const p1=new int[3];//定义了一个指针常量,指针指向的内容可变,但指针为常量
*p1=33;
*(p1+1)=98;
*(p1+2)=9;
const int * const p=p1;//定义了一个指向常量的指针常量,指针和其指向的内容都不可变,类中的const函数中的 指针就为 const<class> *const this;
cout<<*p<<endl;
cout<<*(p+1)<<endl;
- const用法
- const用法
- const用法
- const用法
- const用法
- const 用法
- const用法
- const 用法
- const用法
- const用法
- const用法
- const用法
- const用法
- const用法
- CONST用法
- const用法
- const用法
- const用法
- QT开发工具的安装
- mysql 字符串操作
- “由于没有远程桌面授权服务器可以提供许可证,.....”错误的解决(Server2008R2)
- J2EE初涉
- HUST 1017 Dancing Links 模板
- const 用法
- JAVA Digester 简介
- 数据库名、实例名、全局数据库名、服务名的区别
- 模型-视图-控制器 (MVC)
- Tomcat --> Cannot create a server using the selected type
- 补充更新 小说
- “只有dba才能导入由其他dba导出的文件”的解决方案
- Json 数据格式
- Java XML解析之Digester的使用