C++ Identifiers : TokensPritesh
We have already seen, which are the different types of characters that are considered legal in C++. In this chapter we will be learning the token i.e basic building blocks of C++.
Tokens in C++ :
The group of characters that forms an Basic Building block is called as Token. Tokens are of following 4 types of token in C++ :
A. Token Type 1 : Identifier
Various data items with symbolic names in C++ is called as Identifiers. Following data items are called as Identifier in C++ –
- Names of functions
- Names of arrays
- Names of variables
- Names of classes
The rules of naming identifiers in C++ :
- C++ is case-sensitive so that Uppercase Letters and Lower Case letters are different
- The name of identifier cannot begin with a digit. However, Underscore can be used as first character while declaring the identifier.
- Only alphabetic characters, digits and underscore (_) are permitted in C++ language for declaring identifier.
- Other special characters are not allowed for naming a variable / identifier
- Keywords cannot be used as Identifier.
Some Examples of Identifier in C++ :
|1digit||Invalid||Digit at first location is not allowed|
|digit-1||Invalid||Special characters other than underscore is not allowed|
|num 1||Invalid||Space not allowed|