Website For Developers

Identifiers in C++



Identifiers in c++ are the name, that are used to represent the variables, constant, arrays, function name and other things in the program.
There are two types of identifiers
1. Standard identifiers
2. User-defined identifiers


Standard Identifiers in C++

Standard Identifiers have special meaning in C++.
These are the default identifiers.
Unlike reserved keywords, you can change the name of the standard identifiers but it is NOT recommended.


User-defined identifiers in C++

In C++ program programmers may need to access memory location for storing data. For this purpose memory in which data is stored is named by the user to access it easily afterwards these identifiers are called user-defined identifiers.


Rules for User defined identifiers

• The name of identifier cannot start with a digit.
• Name of identifiers can start with alphabetic or with underscore.
• An identifier in c++ must consist of alphabetic characters(a-z,A-Z), digits(0-9) and underscore (_).
• special characters like $,%,@ are not allowed.
Keywords cannot be used as an identifier.
• Identifiers with upper case and identifiers with lower case are not the same.


Examples of identifiers in C++
Identifiers Validity
hello Valid
3hello Invalid
h3llo Valid
_hello Valid
h@llo Invalid