在定义变量的时候我们需要指定一个名字,作为标志符,标识符的命名必须满足一定的规则:
1.首字母必须以字母或下划线开头;
2.非开头字符除了字母和下划线以外,还可以使用数字;
3、区分大小写;
4.不能使用c++关键字。
//合法变量名
#include<iostream>
using namespace std;
//合法变量名
int main ()
{
int _num = 3;
int num = 4;
int Num = 5;
int n_m = 6;
int n7m = 7;
return 0;
}
//非法变量名
#include<iostream>
using namespace std;
//非法变量名
int main()
{
int 3num =3;
int ?num =4;
return 0;
}
注:以非字母和下滑线开头