21xrx.com
2024-09-20 01:06:05 Friday
登录
文章检索 我的文章 写文章
"C++关键字有几个?"
2023-07-05 11:28:01 深夜i     --     --
C++ 数量

C++是一门广泛使用的编程语言,它的关键字起着极为重要的作用。那么,C++到底有多少个关键字呢?

首先,我们需要明确,C++的关键字是指具有特殊含义的保留字,不能用作标识符或其他用途。在C++中,关键字通常用于定义程序结构、控制程序流程以及声明变量和函数等方面。

经过统计,C++共有72个关键字,以下为它们的完整列表:


and   and_eq  asm   auto  bitand bitor

bool  break  case  catch  char  class

compl  const  constexpr continue  decltype  default

delete do    double dynamic_cast  else  enum

explicit  export extern false  float  for

friend goto  if   inline int   long

mutable namespace  new not not_eq nullptr

operator  or or_eq  private protected  public

register  reinterpret_cast  return short  signed

sizeof static static_assert  static_cast struct switch

template  this  thread_local  throw  true  try

typedef typeid typename  union  unsigned  using

virtual void  volatile  wchar_t while  xor xor_eq

需要注意的是,除了上述72个关键字,C++还有一些预处理指令和运算符等也具有特殊含义,但它们并不算作关键字。比如,预处理指令`#include`、`#define`、`#ifdef`等,以及运算符`+=`、`-= `、`*= `等,都不在关键字范围内。

在日常编程中,掌握C++的关键字以及它们各自的用途,对于编写高效、可靠的代码非常重要。因此,我们需要认真学习和理解这些关键字。

  
  

评论区

{{item['qq_nickname']}}
()
回复
回复