Skip to content Skip to sidebar Skip to footer

Identifiers in C++

Identifiers in C++ are a way of naming things. They are names for variables, functions, classes, and more. The number of unique identifiers is essential because it limits the scope of a variable, for example. Identifiers follow specific rules and provide some protection from mistakes.

In the previous blog, “keywords in c++,” we studied the tokens in which we had mentioned identifiers, so today, we will read about identifiers in detail; if you haven’t checked that blogcheck it once. Carry on.

What are identifiers in C++?

In C++, an identifier is used to identify various entities like classes, modules, variables, constants, functions, and many more.


data_type identifier_name;


int money;   // int is the data type, and money is the identifier.    
char c_for;  // char is the data type, and c_for is the identifier.
string str;  // string is the data type, and str is the identifier.
float random;   // float the data type; random is the identifier.

Since C++ is a case-sensitive programming language, every variation of any word is considered a different identifier in C++.

E.g., Geek, GEEK, geek, etc., are all considered different identifiers.

Rules of Naming identifiers

Now, to name these identifiers, some rules are there we need to follow while naming the identifiers. These rules are common to both the C and C++ programming languages. These are:

  1. The name of the valid identifiers should start with an alphabetic character and can further include only a digit or underscores; no other special characters (like “$” or “#” or “%”) are allowed.


	//valid naming
	int score_100;   
	char changes; 
	float  name_change
	//invalid identifiers
	int score-100;	 
	char #cahnges;   
	float name change;

2. Since C++ is a case-sensitive language, while naming identifiers, uppercase letters and lowercase letters will be considered distinct. 

3. In C++, some words have predefined meanings, known as keywords; hence, we can not use such keywords as identifier names as those are reserved words by the programming language.


So, now you know all about the cpp identifier and can code the fun up (CTFP). Suppose you understood and comprehended this blog properly; well done. You’re getting advanced daily. If, in any case, you’re finding it difficult, you can let us know in the comments & contact us. Besides, if you’ve any doubts, you can post them in the comments. Don’t worry; our geeks will surely get your doubts cleared soon.

Similarly, you must also know that GeekonPeak has just begun and is looking for some loyal supporters so we, the new-gen geeky friends, can grow and create more comprehensive and easy-to-grasp courses for you (for free). Follow us on FacebookInstagram & Twitter as well. Also, don’t miss our newsletter subscription. We provide exclusive blogs, tips, tricks, and advice to program efficiently and market smartly. We also promote some of our partners with excellent experiences to share with you. Until next time 🙂

Leave a comment

Sign Up to Our Newsletter

Be the first to know the latest updates