C++常量关键字标识符的命名规则
发布时间
阅读量:
阅读量
1.常量:
1.1.#define的宏定义
通过 #define 指令可设定常量名及其对应的数值
1.2.const 修饰的变量
利用 const 关键字对数据类型进行限定,随后声明常量名与具体数值
#include<iostream>
using namespace std;
//常量:
//1.#define的宏定义
// #define 常量名 常量值
//2.const 修饰的变量
//const 数据类型 常量名 常量值
#define Day 7
int main()
{
// Day = 14;//Day是常量,不可修改
cout << "Day=" << Day << endl;
//const 修改的变量
const int month = 12;
// month = 16;//const修饰的变量也是常量,不可修改
cout << "一年有" << month << "个月份" << endl;
system("pause");
return 0;
}
全部评论 (0)
还没有任何评论哟~
