天天看點

C++:定義常量的方法

在這裡插入代碼片
#include <iostream>
using namespace std;
//常量的定義方式
//1 #define 宏常量 
//2 const修飾的變量

#define Day 7//注意這裡沒有分号

int main(){
   
    cout << "一周有" << Day << " 天" << endl;
	
    const int month = 12;
    cout << "一年有" << month << "月" << endl;

    system("pause");
    return 0;
}