C++与Java中关键字的区别

关键字(保留字)是编程语言中被赋予特殊意义的单词,是整个语言范围内预先保留的标识符,不能用来声明对象、变量、函数、类名和参数等等标识符。

百科上有详细的解释:C++关键字、Java关键字

C++中的关键字

下面列出了C++(C++11)中的所有关键字(共73个),与Java中不同的用红色标出:

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

Java中的关键字

下面列出了Java中的关键字(共50个):

abstract continue for new switch
assert default goto package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int strictfp try
char final interface short void
class finally long static volatile
const float native super while

你可能感兴趣的:(#,☛,Java,C++)