怎么做猫的静态网站酒店行业的网站建设
1. 什么是 identifier
identifier 中文意思是标识符,在 cppreference 中明确提到,identifier 是任意长度的数字、下划线、大写字母、小写字母、unicode 字符 的序列:
An identifier is an arbitrarily long sequence of digits, underscores, lowercase and uppercase Latin letters, and most Unicode characters
但是:
- identifier 里的 unicode 通常没有被编译器很好的支持
 - 合法的 identifier 的第一个字符,不能是数字
 - C++ 语言的 keywords,也不能作为用户自定义的 identifier

 
2. identifier 有什么用?
identifier 可以用作如下 entities 的命名(naming):
- objects 对象
 - references 引用
 - functions 函数
 - enumerators 枚举元素
 - types 类型
 - class members 类成员
 - namespaces 命名空间
 - templates 模板
 - template specializations 模板特化
 - parameter packs(since C++11) 参数包(从C++11开始)
 - goto labels goto标签
 - other entities 其他 entities
 
并且,还有限制条件:
2.1 C++ keywords 通常不能作为新增的 identifier
作为 keywords 的 identifier,通常只能作为 keyword 使用,不能用于其他情况, 比如 int 是关键字,case 也是关键字,它们不能作为变量、引用、函数、namespace、模板、模板特化的名字;
 
不过也有例外,如 private 用来表示 attribute
 
2.2 alternative representations 不能作为新增的 identifier
alternative representations 指的是 operator_alternative, 我们只需要关注到 and, and_eq, bitand, bitor, compl, not, or, or_eq, xor, xor_eq 不能作为用户自定义的 identifier 的名字即可:
 
2.3 慎用下划线开头的相关名字
如下规则规定了 reserved (保留字)性质的 identifier,用户代码请别用它们作为 identifier:
- 在全局作用域,如果是下划线开头,那么它是保留字,如 
_test,_Test - 双下划线开头,或者下划线+大写字母开头,那么它也是保留字,如 
__test,_Test 
所谓 reserved, 是说标准库的头文件 #define 了或声明了这样的 identifier, 是用于内部使用的
 
总结
identifier 的构成: 是字母、数字、下划线组成的任意长度序列,并且还要求:
- 不能数字开头
 - C++ 语言关键字也是 identifier 但只能用于 keyword,变量、函数、namespace等的命名并不能使用关键字
 - 全局作用域的下划线开头的identifier,或双下划线的identifier、下划线+大写字母开头的identifier,是保留字,用户请别用,除非你是标准库开发者
 
identifier 的一大用处是给 entity 命名,包括:objects、references、functions、enumerators、types、class members、 namespaces、templates、template specializations、parameter packs、goto lables 等
Refs
https://en.cppreference.com/w/cpp/language/identifiers
 https://en.cppreference.com/w/cpp/keyword
 https://en.cppreference.com/w/cpp/language/operator_alternative
