Introduction to C++ Identifiers

  Identifiers in C++




Define Identifiers in C++ 
Types of  Identifiers 
Rules for Declaring an Identifies


Identifiers allude to a unique collection of letters and digits, either short or descriptive, that are utilized to particularly recognize a variable, method, class or some other objects in a programming language. The identifiers in C++ can have identifiers with any length of characters. These characters can be alphanumeric can contain letters, digits and underscores and whitespaces and special characters, for example, @ , # , ! etc are not permitted. These identifiers should begin with a letter or a underscore and are case sensitive in this way keywords should not be utilized as an identifier.All identifiers should follow a portion of the guidelines otherwise won't be recognized by the compiler and mistake will be throws.


Types of  Identifiers: 

Different types of words are identifiers that come into two assortments:

  1. Standard Identifier
  2. User defined Identifier


Standard Identifiers:

Standard identifiers have an speacial significance in C++. They are the names of operations defined in the standard C++ library.


For instance: cout is the name of an I/O operation.


Not at all like  keywords, standard identifiers can be redefined and utilized by the programmer / software engineer for different purposes. In any case, this isn't suggested.


User defined Identifiers:

We chose our own identifiers ( user defined identifier ) to name.

memory cells that will hold data and program results and to name operations that we defined. These names ought to specific guidelines to be acceptable to the C++ compiler. 


Identifiers are utilized to represent or address different objects.


1.Constants

2.Variables

3.Functions

4.Labels

5.Data Types



Rules for Declaring an Identifier:


Lets see a few rules to declare identifiers any other way the compiler will throw an error.


Rule 1: It can be a collection / combination of letters, digits or underscore , no speacial characters, for example, # , $ , ! and @ are permitted in identifiers name.


Rule 2: The 1st character can be either letter or underscores( _ ). This implies if we use digit as the1st character for declare identifier name of an identifier, for example, 1num, it won't be treated as a valid name consequently am error will be throw by the compiler.


Rule 3: These are case sensitive, and that implies Name1 and name1 are not similar identifiers.


Rule 4: A keyword can't be utilized as an identifier. C++ library has a list of keywords utilized for various purposes, for example, if, else, long, int, float, goto, and so on. These variables can't be utilized as an identifier name since there is a reserved for this word defined in the C++ library.


Rule 5: It has no restriction on name length. But some C++ compilers just consider identifiers up to 31 characters.






I hope You Can Easily Understand and Learn This Article

Best of Luck 

Post a Comment

0 Comments