在C++中总共有95个保留词。C++的保留字可以方便地放置到多个组中。在第一组中,我们将那些也存在于C编程语言中并已经被移植到C++中。一共有32个。
还有30个不在C中的保留字,因此对C ++来说是新的
当使用标准ASCII字符集时,有11个C++保留字不是必需的,但是它们被添加以提供一些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 |