Open In App

C++ Keywords

Last Updated : 23 Dec, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Keywords are the reserved words that have special meanings in the C++ language. They are the words that the language uses for a specifying the components of the language, such as void, int, public, etc. They can’t be used for a variable name or function name or any other identifiers.

Let’s take a look at the hello world code:

C++
#include <iostream>
using namespace std;

int main() {
  
    cout << "Hello World";
  
    return 0;
}

Output
Hello World

Explanation: In the above code, using, namespace, and return are the keywords that are used to implement some functionality of the language. Their meaning is predefined in C++ and will always remain same.

The total number of keywords in C++ are 95 upto C++ 23 specification. Below is the table for all C++ keywords:

alignasalignofandand_eqasm
autobitandbitorboolbreak
casecatchcharchar8_tchar16_t
char32_tclasscomplconceptconst
constevalconstexprconstinitconst_castcontinue
co_awaitco_returnco_yielddecltypedefault
deletedodoubledynamic_castelse
enumexplicitexportexternfalse
finalfloatforfriendgoto
ifinlineintlongmutable
namespacenewnoexceptnotnot_eq
nullptroperatororor_eqprivate
protectedpublicregisterreinterpret_castrequires
returnshortsignedsizeofstatic
static_assertstatic_caststructswitchtemplate
thisthread_localthrowtruetry
typedeftypeidtypenameunionunsigned
usingvirtualvoidvolatilewchar_t
whilexorxor_eq

Keywords vs Identifiers

So, there are some properties of keywords that distinguish keywords from identifiers. They listed in the below table

Keywords Identifiers
Keywords are predefined/reserved words identifiers are the values used to define different programming items like a variable, integers, structures, and unions.
It defines the type of entity.It classifies the name of the entity.
A keyword contains only alphabetical characters, an identifier can consist of alphabetical characters, digits, and underscores.
It should be lowercase.It can be both upper and lowercase.
No special symbols or punctuations are used in keywords and identifiers. No special symbols or punctuations are used in keywords and identifiers.  The only underscore can be used in an identifier.
Example: int, char, while, do.Example: Geeks_for_Geeks, GFG, Gfg1.

Next Article
Article Tags :
Practice Tags :

Similar Reads

three90RightbarBannerImg
  翻译: