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

C++ มีคีย์เวิร์ด (keywords) ทั้งหมดกี่คำ?

มีคำสงวน (reserved words) ทั้งหมด 95 คำใน C++ คำสงวนของ C++ สามารถจัดกลุ่มได้หลายกลุ่ม กลุ่มแรกคือคำที่มีอยู่ในภาษา C และถูกนำมาสู่ C++ จำนวน 32 คำ

มีคำสงวนอีก 30 คำที่ไม่อยู่ใน C จึงเป็นคำใหม่ใน C++

มีคำสงวน 11 คำที่ไม่จำเป็นเมื่อใช้ชุดตัวอักษร ASCII มาตรฐาน แต่ถูกเพิ่มเข้ามาเพื่อให้ทางเลือกที่อ่านง่ายกว่าสำหรับออปอเรเตอร์บางตัวของ C++ และเพื่ออำนวยความสะดวกในการเขียนโปรแกรมกับชุดตัวอักษรที่ขาดตัวอักษรที่ C++ ต้องการ

นี่คือรายการคำสงวนทั้งหมด:

alignas (since C++11) alignof (since C++11) and
and_eq asm atomic_cancel (TM TS)
atomic_commit (TM TS) atomic_noexcept (TM TS) auto
bitand bitor bool
break case catch
char char16_t (since C++11) char32_t (since C++11)
class compl concept (since C++20)
const constexpr (since C++11) const_cast
continue co_await (coroutines TS) co_return (coroutines TS)
co_yield (coroutines TS) decltype (since C++11) default
delete do double
dynamic_cast else enum
explicit export extern
false float for
friend goto if
import (modules TS) inline int
long module (modules TS) mutable
namespace new noexcept (since C++11)
not not_eq nullptr (since C++11)
operator or or_eq
private protected public
register reinterpret_cast requires (since C++20)
return short signed
sizeof static static_assert (since C++11)
static_cast struct switch
synchronized (TM TS) template this
thread_local (since C++11) throw true
try typedef typeid
typename union unsigned
using virtual void
volatile wchar_t while
xor xor_eq