English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C++ Basic Tutorial

C++ Flow Control (流程控制)

C++ Function (函数)

C++ Array & String (数组 & 字符串)

C++ Data Structure (数据结构)

C++ Class & Object (类 & 对象)

C++ Pointer (指针)

C++ Inheritance (继承)

C++ STL Tutorial (STL教程)

C++ Reference Manual

c++ Keywords and Identifiers

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.

C++ Keywords

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)

alignasdecltypenamespacestruct
alignofdefaultnewswitch
anddeletenoexcepttemplate
and_eqdonotthis
asmdoublenot_eqthread_local
autodynamic_castnullptrthrow
bitandelseoperatortrue
bitorenumortry
boolexplicitor_eqtypedef
breakexportprivatetypeid
caseexternprotectedtypename
catchfalsepublicunion
charfloatregisterunsigned
char16_tforreinterpret_castusing
char32_tfriendreturnvirtual
classgotoshortvoid
complifsignedvolatile
constinlinesizeofwchar_t
constexprintstaticwhile
const_castlongstatic_assertxor
continuemutablestatic_castxor_eq

Note:Due to C ++is case-sensitive language, so all keywords must be written in lowercase letters.

C++ Identifier

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.

Identifier naming rules

  • 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.

Example of good and bad identifiers

Illegal identifierInvalid identifierGood identifier
Total pointsT_pointstotalPoint
1listlist_1list1
floatn_floatfloatNumber