首页 > 编程语言 > 详细

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

时间:2020-06-11 20:05:52      阅读:42      评论:0      收藏:0      [点我收藏+]

变量的例子

#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;

}

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!