const和define
来源:互联网 发布:淘宝清杂款衣服店铺 编辑:程序博客网 时间:2024/06/15 17:59
在C语言中,经常用define来定义符号常量。
格式:#define name value
例如:#define PI 3.14
在C++中,也可以用C语言中的常用格式来定义符号常量,但是它又提供了一种更好的方法,那就是const限定符。
格式:const type name = value
例如:const double pi = 3.14
const与define相比具有一下优点:
1、它能够指定数据类型;
2、可以使用C++的作用域规则将定义限制在特定的函数或文件中;
3、可以将const用于更复杂的类型。
0 0
- const和#define
- #define和const区别
- const 和 #define
- #define、const和enum
- define const 和 typedef
- define 和 const
- const 和 define
- #define、const和enum
- define和const区别
- const和define异同
- const和define区别
- const 和 #define区别
- const和#define
- const和define
- const和#define区别
- const 和 #define区别
- const 和 #define区别
- const 和 #define区别
- php中的设计模式之--命令模式
- “Ceph浅析”系列之一——前言
- android 重启 adb 遇到 Make sure the plugin is properly configured
- 饿了么、百度、美团外卖,网上订餐成为白领用餐的新趋势
- should be mapped with insert="false" update="false"
- const和define
- 字符串形式十六进制数转换
- Linux 命令-mpstat -P ALL
- ORACLE DUMP 的用法
- HDU2046 骨牌铺方格
- Android技术——数据库(二):SQLite数据库的建立和维护
- LeetCode LRU Cache
- LNK4098: 默认库“MSVCRT”与其他库的使用冲突
- synchronized 分析