In C++, an identifier is a name given to various program elements such as variables, functions, classes, etc. Identifiers are used to uniquely identify these elements within the program.
An identifier in C++ is a sequence of characters (letters, digits, and underscores) that serves as a name for various program elements, such as variables, functions, classes, etc.
myVariable _count calculateSum ClassName MAX_SIZE daysOfWeek my_function
2ndValue (starts with a digit) class (reserved keyword) my variable (contains space) my-variable (contains special character) sum# (contains special character)
int age; float salary;
void greetUser() { } int calculateSum(int a, int b) { }
startLoop: // loop code goto startLoop;
const int MAX_SIZE = 100;
class Student { // class members };
struct StructureName { // Member declarations };
union UnionName { // Member declarations };
Student s1;
enum DaysOfWeek { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
class MyClass { public: int myNumber; // Declaration of a data member };
class MyClass { public: void myFunction(int x, int y); // Declaration of a member function };
typedef int Name; Name myNumber = 5;
#define SQUARE(x) ((x) * (x))
#define MACRO_NAME(parameter_name) // Macro definition
namespace math { // namespace contents }
templateclass Container { // class members };