目录
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;
}