C++中的保留關鍵字?
保留字是不能用作識別符號的單詞,例如變數、函式或標籤的名稱——它是“保留不用”的。這是一個語法定義,保留字可能沒有意義。
C++中共有95個保留字。C++的保留字可以方便地分成幾個組。在第一組中,我們列出了那些也存在於C程式語言中並被移植到C++中的保留字。其中有32個。
還有30個保留字不在C中,因此是C++程式語言的新增內容。
有11個C++保留字在使用標準ASCII字元集時不是必需的,但它們已被新增以提供一些C++運算子更易讀的替代方案,並方便使用缺少C++所需字元的字元集進行程式設計。
以下是所有這些保留字的列表:
| alignas (自C++11起) | alignof (自C++11起) | and |
| 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 (自C++11起) |
| char32_t (自C++11起) | class(1) | compl |
| concept (自C++20起) | const | constexpr (自C++11起) |
| const_cast | continue | co_await (協程TS) |
| co_return (協程TS) | co_yield (協程TS) | decltype (自C++11起) |
| default(1) | delete(1) | do |
| double | dynamic_cast | else |
| enum | explicit | export(1) |
| extern(1) | false | float |
| for | friend | goto |
| if | import (模組TS) | inline(1) |
| int | long | module (模組TS) |
| mutable(1) | namespace | new |
| noexcept (自C++11起) | not | not_eq |
| nullptr (自C++11起) | operator | or |
| or_eq | private | protected |
| public | register(2) | reinterpret_cast |
| requires (自C++20起) | return | short |
| signed | sizeof(1) | static |
| static_assert (自C++11起) | static_cast | struct(1) |
| switch | synchronized (TM TS) | template |
| this | thread_local (自C++11起) | throw |
| true | try | typedef |
| typeid | typename | union |
| unsigned | using(1) | virtual |
| void | volatile | wchar_t |
| while | xor | xor_eq |
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP