声明
标识符
C++ 的 标识符 由字母、数字和下划线组成:
- 必须以字母或下划线开头
- 长度无限制
- 对大小写字母敏感
避免 C++ 保留名字:
-
C++ 保留关键字
// C++关键字
alignas continue friend register true
alignof decltype goto reinterpret_cast try
asm default if return typedef
auto delete inline short typeid
bool do int signed typename
break double long sizeof union
case dynamic_cast mutable static unsigned
catch else namespace static_assert using
char enum new static_cast virtual
char16_t explicit noexcept struct void
char32_t export nullptr switch volatile
class extern operator template wchar_t
const false private this while
constexpr float protected thread_local
const_cast for public throw
// C++操作符替代名
and bitand compl not_eq or_eq xor_eq
and_eq bitor not or xor -
以连续两个下划线开头
-
以下划线紧连大写字母开头