Skip to content
Home » C++ Identifiers

C++ Identifiers

    C++ identifiers are names that identify program elements such as variables using alphabets, numbers, and underscore.

    Here is the list of characters for:

    • Alphabets:
    • Numbers:
    • Underscore:

    Any other character from your keyboard that does not fall under the above category is called a special character. The uppercase and lowercase are distinct characters. They have different numeric values according to ASCII standard.

    There is no limit for the number of characters used as , but some compiler put limitation by recognizing first characters as name. You should read the compiler documentation to get the information.

    Rules for Variable Names

    The C++ identifiers are used for variable names. We must learn the rules to give valid names to variables. The names must contain allowed characters.

    My_var
    Table
    S
    R

    The above are some valid names.

    5chair
    speeed$boat
    three dimension

    The above three variable names are invalid because:

    • variable names cannot begin with a number
    • special characters are not allowed
    • whitespace is not allowed for variable names.

    C++ Keywords

    Keywords are special identifiers because they are reserved by the compiler. You cannot use them as variable names and they are case sensitive.

    Here is a list of C++ keywords.

    asmautobreakcasecatchchar
    classconstcontinuedefaultdeletedo
    doubleelseenumexternfloatfor
    friendgotoifinlineintlong
    newoperatorprivateprotectedpublicregister
    returnshortsignedsize ofstaticstruct
    switchtemplatethisthrowtrytypedef
    unionunsignedvirtualvoidvolatilewhile

    Note that sometimes one or more keywords are used together.

    Exit mobile version