其他分享
首页 > 其他分享> > 02 循序渐进——变量和常量

02 循序渐进——变量和常量

作者:互联网

01 变量基础概念

作用:给一段制定的内存空间起名,方便操作这段内存,管理内存空间

语法:数据类型 变量名=初始值

 

 02 常量基础概念

作用:记录程序中不可更改的数据

定义方式:

(a)#define 常量名 常量值——define宏常量,通常在文件上方定义

(b)const 数据类型 常量名 = 常量值——通常在变量定义前加关键字const

#include<iostream>
using namespace std;
#define Day 7//定义宏常量
int main()
{
    
    const int a = 10;//定义变量-常量
    cout <<"一周总共有:"<<Day<<"天"<<endl;
    system("pause");
    return 0;
}

 

标签:02,const,常量,数据类型,定义,循序渐进,变量,define
来源: https://www.cnblogs.com/Pygoupfs/p/15346968.html