在C++中总共有95个保留词。C++的保留字可以方便地放置到多个组中。在第一组中,我们将那些也存在于C编程语言中并已经被移植到C++中。一共有32个。
还有30个不在C中的保留字,因此对C++来说是新的
当使用标准ASCII字符集时,有11个C++保留字不是必需的,但是它们被添加以提供一些C++操作符更可读的替代品,并且还便于用缺少C++所需字符的字符集编程。
这是所有这些保留字的列表:
alignas(sinceC++11)
| alignof(sinceC++11)
| and
| and_eq
| asm
| atomic_cancel(TMTS)
|
atomic_commit(TMTS)
| atomic_noexcept(TMTS)
| auto(1)
|
bitand
| bitor
| bool
|
break
| case
| catch
|
char
| char16_t(sinceC++11)
| char32_t(sinceC++11)
|
class(1)
| compl
| concept(sinceC++20)
|
const
| constexpr(sinceC++11)
| const_cast
|
continue
| co_await(coroutinesTS)
| co_return(coroutinesTS)
|
co_yield(coroutinesTS)
| decltype(sinceC++11)
| default(1)
|
delete(1)
| do
| double
|
dynamic_cast
| else
| enum
|
explicit
| export(1)
| extern(1)
|
false
| float
| for
|
friend
| goto
| if
|
import(modulesTS)
| inline(1)
| int
|
long
| module(modulesTS)
| mutable(1)
|
namespace
| new
| noexcept(sinceC++11)
|
not
| not_eq
| nullptr(sinceC++11)
|
operator
| or
| or_eq
|
private
| protected
| public
|
register(2)
| reinterpret_cast
| requires(sinceC++20)
|
return
| short
| signed
|
sizeof(1)
| static
| static_assert(sinceC++11)
|
static_cast
| struct(1)
| switch
|
synchronized(TMTS)
| template
| this
|
thread_local(sinceC++11)
| throw
| true
|
try
| typedef
| typeid
|
typename
| union
| unsigned
|
using(1)
| virtual
| void
|
volatile
| wchar_t
| while
|
xor
| xor_eq
|
|