Tokens In C++ Programming Language


Every c++ program is made up of small and individual units and they are known as tokens in c++. In this post, you will learn all the tokens in the c++ and they are:

  1. Keywords
  2. Identifiers
  3. Constants
  4. Strings
  5. Operators

A complete c++ program contain tokens, white spaces and all the syntaxes. Most of the tokens are same as the c programming. But c++ has some additional tokens. Now, let us study these one by one.


These are some special words whose meaning is already known to the compiler. We can call these keywords as reserved words. Whenever we will use these keywords, compiler will automatically understand what it has to do.

You can not use them as the general identifier in your program. There are some common keywords between c and c++. The following table shows the c++ keywords.

virtualvoid volatilewhile
C++ Keywords

There are also some keywords which are added by ANSI C++ and they are

ANSI C++ Keywords


Identifiers are nothing but a name of a variable or variables, functions, arrays, classes, etc. Programmer gives these names but there are certain rules and they are

  1. Identifiers can have only alphabets, digits and underscore. You can not use other than this for declaring an identifiers. For example, vijay@123 is an invalid identifier because we have used ‘@’ here.
  2. The name of an identifier will start with alphabet or underscore. You can not use digits at the beginning of the identifier. For example, 123_vijay is an invalid identifier because there is digit at the beginning.
  3. Like c programming, c++ is also a case sensitive language. That means uppercase letters and lowercase letters are not the same. For example, Vijay and vijay are different for c++ compiler.
  4. We can not use keyword as an identifier. We know, keyword has fixed meaning which is already known to the compiler.

Before declaring and using an identifier, we must remember these rules.


Constants values do not change throughout the c++ program. In other words, we can say constant is an entity whose value will not change. For example, 876 is a constant value. It will remain same. So basically we have integer constant, floating point constant, character constant, string constant in c++ and so on.

In the c++ programming, we can declare a constant using the qualifier const. See the following example.

const int num = 50;

After this statement, you can not modify the value of num because now it becomes constant and hence, we will not be able to change it.


Strings are nothing but a collection of characters. We can also define a string as a character array. Whatever we will write in the double quotation, it becomes string constant.

There is also another way to declare a string. See the following program.

#include <iostream>
using namespace std;
int main()
    string name;
    cout<<"Enter your name\n";
    cout<<"Hello, "<<name;
    return 0;

Here, instead of using character array, we have declared the variable name of type string. We can not do this in c programming. See the following output.

Enter your name
Hello, Vijay

Operators in C++

All the operators in c programming can be used in c++. But there are some operators in c++ which you can not use in c programming. So, I have already written the post on operators in c programming. You can read that post. These operators you can use in c++. The following table is showing operators in c++ which are newly introduced.

<<Insertion operator
>>Extraction operator
: :Scope resolution operator
: : *Pointer to member declarator
->* or .*Pointer to member operator
newIt allocates memory
deleteRelease memory
endlLine feed operator works just like \n
setwField width operator
Operators in C++

So, these are tokens in c++. This is just a very basic article. I hope, you have understood these tokens in c++. If you have any problems then please feel free to contact me.

Thank you.

You may also like

  1. A Simple C++ Program with Explanation
  2. Best 5 Basic C++ Programs For Beginners
  3. C++ Program to Read and Display Student Details using Class
  4. Simple Interest Program in C++ using Class

Leave a Comment