c++ 1注释 2变量 3常量

变量的例子

#include<iostream>

using namespace std;

int main(){

int a = 10;

//打印出a=10

cout << "a="<<a<<endl;

system("pause");

return 0;

}

3常量的例子

/*

3.1宏常量   #define 常量名  常量值   (通常在文件上方定义,表示一个常量)

3.2const修饰的变量  const 数据类型 常量名=常量值(通常在变量定义前加关键字const,修饰该变量为常量,不可修改)

*/

#define day 7

#include<iostream>

using namespace std;

int main(){

//打印出一周共有7天

cout << "一周共有:"<<day<<"天"<<endl;

system("pause");

return 0;

}

原文地址:https://www.cnblogs.com/fanqiusha1988/p/13095447.html