C++学习笔记——NO.1初识C++

目录

1.1 简单的C++程序

1.2 C++常量

1.3 标识符命名规则


1.1 简单的C++程序

一、程序注释

    单行注释//

    多行注释/*   */

#include <iostream>
using namespace std;
int main()
{
	//在屏幕上输出Hello World!
	cout << "Hello World!" << endl;
	system("pause");
	return 0;
}

1.2 C++常量

C++常量主要两种

1.define定义的宏常量

    #define  AGE  27

2.const修饰的变量

    const  int  AGE  =  7;

#include <iostream>
using namespace std;
#define AGE1 27
int main()
{
	// 1.宏常量
	cout << "luka的年龄为:" << AGE1 <<endl;
	
	//2.cnost修饰的变量
	const int AGE2 = 7;
	cout<< "luka的年龄为:" << AGE2 << endl;

	system("pause");
	return 0;
}

1.3 标识符命名规则

标识符的命名规则:

1.由英文字母大小写、数字和_组成;

2.标识符命名不能以数字开头;

3.标识符中不能包含空格;

4.不可以使用关键字;

5.C++中严格区分大小写;

#include <iostream>
using namespace std;
int main()
{
	int _luka = 7;
	int dwh_luka = 14;
	int luka77 = 17;
	cout << _luka << endl;
	cout << dwh_luka << endl;
	cout << luka77 << endl;

	system("pause");
	return 0;
}

  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值