关键字

关键字(keyword)又称保留字,是整个语言范围内预先保留的标识符。每个C++关键字都有特殊的含义。经过预处理后,关键字从预处理记号(preprocessing-token)中区别出来,剩下的标识符作为记号(token),用于声明对象、函数、类型、命名空间等。不能声明与关键字同名的标识符。

ISO C++98/03关键字共63个,此处严格按标准原文排版:

asm do if return typedef
auto double inline short typeid
bool dynamic_cast int signed typename
break else long sizeof union
case enum mutable static unsigned
catch explicit namespace static_cast using
char export new struct virtual
class extern operator switch void
const false private template volatile
const_cast float protected this wchar_t
continue for public throw while
default friend register true
delete goto reinterpret_cast try

C++11 关键字共73个。
新增关键字:alignasalignofchar16_tchar32_t、constexpr、decltype、noexcept、nullptr、static_assert、thread_local。
auto 的意义改变。
register 被视为过时的(可能在未来标准移除)。
export 因为实现支持太少(仅Edison Design Group的前端支持),编译效率低下,取消原有意义(仍是关键字,但使用它的程序是错误的),改为保留给未来标准使用。