const
来源:互联网 发布:白酒网络营销策划书 编辑:程序博客网 时间:2024/06/07 00:05
来看下面一段代码:
#include <iostream>using namespace std;int main(){const int MAX_NUM = 731;const string EMAIL = "x-lion@xxx.edu.cn";//MAX_NUM = 130;// expression must be a modifiable lvaluedint a, b;const int* p = &a;//*p = 5;// expression must be a modifiable lvalueda = 5;//OKp = &b;int* pp = new int;p = pp;//pp = p;//a value of type "const int*" cannot be assigned to an entity of type "int *" 为什么? 因为我们倾向于不修改const int* 指向的值。pp = (int*) p;//当然我们还是可以强制赋值的。int c;const int& d = c;//d = 99;// expression must be a modifiable lvaluedc = 99;return 0;}void MyPrintf(const char* p){//strcpy(p, "C++");//argumrnt of type "const char*" is incompatible with parameter of type "char*"printf("%s", p);}
0 0
- const
- const
- const
- CONST
- const
- const
- const
- const
- const
- const
- Const
- const
- const
- const
- CONST
- const
- const
- const
- Java中Map的使用
- 使用ZeroMQ彻底重构OpenVPN的设想以及一些新想法
- 1073成绩排名
- Android五大布局Layout
- 启动eclipse的时候都要在android sdk content loader 持久性问题
- const
- sublime text 3插件-Emmet Css Snippets
- 简单基本的sql语句
- BZOJ 3904 最长上升子序列 lkids 线段树
- Graphviz JAVA API
- Linux(MAC) SSH远程文件/目录传输命令scp
- 一起学习 POI (使用 maven 构建)(3)-为单元格数据设置对齐、边框、背景、合并单元格
- 编写高性能的JavaScript事件
- short 型转换成int型