English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In this tutorial, we will learn about keywords (C ++Reserved keywords in programming, which are part of the syntax). We will also learn about identifiers and how to name them.
Keywords arePredefinedwords have special meanings to the compiler. For example,
int money;
Here, int is a keyword indicating that money is a variable of integer type.
This is all C ++List of keywords. (From C ++ 17Start)
alignas | decltype | namespace | struct |
alignof | default | new | switch |
and | delete | noexcept | template |
and_eq | do | not | this |
asm | double | not_eq | thread_local |
auto | dynamic_cast | nullptr | throw |
bitand | else | operator | true |
bitor | enum | or | try |
bool | explicit | or_eq | typedef |
break | export | private | typeid |
case | extern | protected | typename |
catch | false | public | union |
char | float | register | unsigned |
char16_t | for | reinterpret_cast | using |
char32_t | friend | return | virtual |
class | goto | short | void |
compl | if | signed | volatile |
const | inline | sizeof | wchar_t |
constexpr | int | static | while |
const_cast | long | static_assert | xor |
continue | mutable | static_cast | xor_eq |
Note:Due to C ++is case-sensitive language, so all keywords must be written in lowercase letters.
Identifiers are unique names given by programmers to variables, classes, functions, or other entities. For example,
int money; double accountBalance;
Here, money and accountBalance are identifiers.
Identifiers can consist of letters, digits, and underscore characters.
There is no limit to the length of the name.
It must start with a letter or underscore.
Case sensitive.
We cannot use keywords as identifiers.
If we follow the above rules, we can choose any name as an identifier. However, we should provide meaningful names for meaningful identifiers.
Illegal identifier | Invalid identifier | Good identifier |
---|---|---|
Total points | T_points | totalPoint |
1list | list_1 | list1 |
float | n_float | floatNumber |