C++ operators, keywords and tokens


The C++ was developed by Bjarne Stroustrup at AT&T Bell laboratories. He found ‘C’ lacking for simulations and decided to extend the language by adding features form his favorite language, Simula 67.  Simula 67 was the earliest object-oriented languages. Bjarne Stroustrup called it “C with classes” originally. The name C++ (pronounced C++) was coined by Rick Mascitti where “++” is the C increment operator.

C++ Character Set:-

It is a set of valid characters. A character set represents any digit, letter, or any other sign.

TOKENS (Lexical units)

Individual words and punctuation marks are called token or lexical units or lexical element. C++ has the following tokens :

  •   Keywords
  •   Identifiers
  •   Literals
  •   Punctuators
  •   Operators

The original C++ contains the following keyword:-

example :- continue, goto, new, float, int, char, try, auto, default, for, operator, delete, typedef, friend etc.


“It is long sequence of letters and digits. Upper and lower case letters are different. All characters are significant.

The following are some valid identifier:-

               Myfile                       Dated_7_77                    Z2T0Z9
               MYFILE                      _DS                              _HJI3_JK
               _CHK                         FILE13

The following are some invalid identifiers:-

     DATA-REC                   contain special character –(other than A-Z,a-z, and _ )
     2CLCT                             starting with a digit
     Break                              reserved keyword
     My.file                            contain special character dot (.)


Literals are data items which never change their value when a is program run.

C++ allows several kinds of literals:-

  •       bool literal
  •       integer-constant
  •       character-constant
  •       floating constant
  •       String-literal

An integer constant must have at least one digit and must have not contained any decimal point. It may contain either + or – sign.

C++ allows three type of integer constant:-

·      Decimal (base 10)
·      Octal (base 8)
·      Hexadecimal (base 16)

Floating constants:- 

 Real constants are numbers having factorials parts. This may be written in one of the two forms called fractional form or the exponent form.


The following character are used as punctuators (also known as separators) is C++ :
           [     ]       (      )         {      }   ,  ;   :     *    ...    =    #

Unary operators:-

Address operator
Indirection operator
Unary plus
Unary minus
Bitwise complement
Increment operator
Decrement operator
Logical negation

Binary Operator:-

 Following are some binary operators:
                                 Arithmetic Operators 

It provides operators for five basic arithmetic calculation: addition, subtraction, multiplication, division and remainder which are +, -, *, /, and % respectively.

                                   Shift Operators  
Shift left
Shift right

                                   Bitwise operators
Bitwise AND
Bitwise exclusive OR (XOR)
Bitwise OR

                                   Logical operators 
This section talks about logical operators that refer to the ways these relationships can be connected.
Logical AND
Logical OR

                                  Assignment operator 

Assign quotient
Assign sum
Assign left  shift
Assign bitwise AND
Assign product
Assign remainder
Assign difference
Assign right shift
Assign bitwise XOR

                                   Relational operators

 The relationship operators determine the relation among different operand. The six relational operators are:

.Less than
Greater than
Less than or equal to
Greater than or equal to
Equal to
Not equal to

                                 Class member operator
Scope access /resolution
Deference pointer to class member
Deference pointer to class member