C++ 中有多少个关键字?
c++programmingobject oriented programming
C++ 中总共有 95 个保留字。C++ 的保留字可以方便地分为几组。第一组中,我们放入了 C 编程语言中也存在并已延续到 C++ 中的保留字。一共有 32 个这样的保留字。
还有 30 个保留字在 C 中没有,因此对 C++ 来说是新保留字
有 11 个 C++ 保留字在使用标准 ASCII 字符集时不是必需的,但它们被添加是为了为某些 C++ 运算符提供更易读的替代方案,也是为了方便使用缺少 C++ 所需字符的字符集进行编程。
以下是所有这些保留字的列表:
alignas (since C++11) | alignof (since C++11) | and |
and_eq | asm | atomic_cancel (TM TS) |
atomic_commit (TM TS) | atomic_noexcept (TM TS) | auto(1) |
bitand | bitor | bool |
break | case | catch |
char | char16_t (since C++11) | char32_t (since C++11) |
class(1) | compl | concept (since C++20) |
const | constexpr (since C++11) | const_cast |
continue | co_await (coroutines TS) | co_return (coroutines TS) |
co_yield (coroutines TS) | decltype (since C++11) | default(1) |
delete(1) | do | double |
dynamic_cast | else | enum |
explicit | export(1) | extern(1) |
false | float | for |
friend | goto | if |
import (modules TS) | inline(1) | int |
long | module (modules TS) | mutable(1) |
namespace | new | noexcept (since C++11) |
not | not_eq | nullptr (since C++11) |
operator | or | or_eq |
private | protected | public |
register(2) | reinterpret_cast | requires (since C++20) |
return | short | signed |
sizeof(1) | static | static_assert (since C++11) |
static_cast | struct(1) | switch |
synchronized (TM TS) | template | this |
thread_local (since C++11) | throw | true |
try | typedef | typeid |
typename | union | unsigned |
using(1) | virtual | void |
volatile | wchar_t | while |
xor | xor_eq |