const in C and C++
来源:互联网 发布:睿医人工智能研究中心 编辑:程序博客网 时间:2024/04/29 02:19
C和C++的const关键字是不一样的,
在C里,const定义的并非真正的常量,它实际上是只读的变量,即不允许修改它,本质上还是个变量,
用#define定义的才是真正的常量,因此,你这样定义的时候,会报错:
error C2057: expected constant expression
提示你size并非常量表达式
但在C++里面,const定义的就是真正的常量,可以用来定义数组。
0 0
- const and pointer in c
- const in C and C++
- Const and volatile in C language
- const in C&&C++
- Const Correctness in C++(转)
- The different between #define and const for a constant in C
- some cases about "const" in C Program
- Key word:const in C language
- NULL and NUL in C
- Multithreading in C and Java
- Strings in C and C++
- Modulo in Python and C
- socket in C and Java
- array and pointer in c
- memset in C++ and C
- operator in C and C++
- #define vs const in Objective-C 用 #define 还是 const
- Sort and Search in C and C++
- 【codeforces #10 】
- 解决mysql"Access denied for user'root'@'IP地址'"问题
- ADF BC bc4j.xcfg专贴
- 数据结构——算法之(043)(c++各种排序算法实现)
- NYOJ 353 3D dungeon(三维数组BFS)
- const in C and C++
- 软件开发-人员流动
- 组播路由协议原理
- Linux sftp 的用法
- html5调用手机摄像头,实现拍照上传功能
- C++ STL之map详解
- 2014 BAT 面试经验 自律用~
- 人人都看得懂的正则表达式教程
- xcodeproj cannot be opened because the project file cannot be parsed.