Advertisement
คำสงวน (Reserved Word)
เป็นคำเฉพาะที่ได้กำหนดขึ้นมา เพื่อใช้ในตัวภาษาโดยเฉพาะ ซึ่งผู้เขียนโปรแกรมไม่สามารถนำมาใช้เป็นชื่อ (Indentifiers) ได้ เช่น ไม่สามาถนำไปใช้เป็นตัวแปร (Variables) หรือ ชื่อโปรแกรมได้
คำสงวนในภาษาซี
ตามมาตรฐานสถาบันมาตรฐานแห่งชาติสหรัฐอเมริกา (American National Standards Institute) มี 32 คำ ดังนี้
Advertisement
| auto | break | case | char |
| const | continue | default | do |
| double | else | enum | extern |
| float | for | goto | if |
| int | long | register | return |
| short | signed | sizeof | static |
| struct | switch | typedef | union |
| unsigned | void | volatile | while |
คำสงวนในภาษาซีพลัสพลัส
ได้เพิ่มมาจากคำสงวนในภาษาซี อีก 30 คำ ดังนี้
| asm | bool | catch | class |
| const_cast | delete | dynamic_cast | explicit |
| false | friend | inline | mutable |
| namespace | new | operator | private |
| protected | public | reinterpret_cast | static_cast |
| template | this | throw | true |
| try | typeid | typename | using |
| virtual | wchar_t |
Advertisement