Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C++

Reserved Keywords (คำสงวน) ใน C++


นิยาม

Reserved word คือคำที่ไม่สามารถใช้เป็น identifier ได้ (เช่นชื่อตัวแปร ฟังก์ชัน หรือ label) ถูก "สงวนไว้" ไม่ให้ใช้งาน นี่เป็นนิยามทาง syntax คำสงวนอาจไม่มีความหมายด้วยตัวเอง

สถิติ

  • รวม 95 คำสงวนใน C++
  • 32 คำมาจาก C language
  • 30 คำใหม่เฉพาะ C++
  • 11 คำเป็นตัวเลือกสำหรับ character set ที่ขาดบางตัวอักษร (alternative tokens)

รายการคำสงวนทั้งหมด (บางส่วน)

คำสงวนคำสงวนคำสงวน
alignas (C++11)alignof (C++11)and
and_eqasmatomic_cancel (TM TS)
atomic_commit (TM TS)atomic_noexcept (TM TS)auto
bitandbitorbool
breakcasecatch
charchar16_t (C++11)char32_t (C++11)
classcomplconcept (C++20)
constconstexpr (C++11)const_cast
continueco_await (coroutines TS)co_return (coroutines TS)
co_yield (coroutines TS)decltype (C++11)default
deletedodouble
dynamic_castelseenum
explicitexportextern
falsefloatfor
friendgotoif
import (modules TS)inlineint
longmodule (modules TS)mutable
namespacenewnoexcept (C++11)
notnot_eqnullptr (C++11)
operatororor_eq
privateprotectedpublic
registerreinterpret_castrequires (C++20)
returnshortsigned
sizeofstaticstatic_assert (C++11)
static_caststructswitch
synchronized (TM TS)templatethis
thread_local (C++11)throwtrue
trytypedeftypeid
typenameunionunsigned
usingvirtualvoid
volatilewchar_twhile
xorxor_eq