常量-常量与变量的区别-常量的使用

  • 常量不可更改
  • const修饰的变量也称为常量
点击查看代码
#include<iostream>
#include<string>

using namespace std;

//常量的定义方式 
// 1、#define宏常量 
#define WEEK 7
// 2、const修饰的变量,const修饰的变量也称为常量
const int month = 12;

int main()
{
	cout << WEEK << "天" << endl;
	cout << month << "月" << endl;

	system("pause");

	return 0;
}
posted @ 2021-07-22 16:29  毋纵年华  阅读(145)  评论(0)    收藏  举报