A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/cpp/cpp-identifiers/ below:

C++ Identifiers - GeeksforGeeks

C++ Identifiers

Last Updated : 23 Jul, 2025

In C++ programming language, identifiers are the unique names assigned to variables, functions, classes, structs, or other entities within the program. Let's take a look at an example:

C++
// Creating a variable
int val = 10;

// Creating a function
void func() {}

In the above code, the words val and func are identifiers. Basically, everything named by a programmer is an identifier and is used to refer to the entity later in the program.

Rules to Name of an Identifier

We can use any word as an identifier as long as it follows the following rules:

Additionally, C++ is a case-sensitive language so the identifier such as Num and num are treated as different. The below images show some valid and invalid C++ identifiers.

To know more about identifiers naming rules, refer to this article – Naming Convention in C++

Example of Valid/Invalid Identifiers Example

In this example, we have used the identifiers by following the guidelines and we use identifiers to name a class, function, integer data type, etc. If you are not aware of functions and classes in C++ then don’t worry, you will learn them soon. The below code is run successfully which means we named them correctly.

C++
#include <iostream>
using namespace std;

// Here Car identifier is used to refer to below class
class Car {
    string Brand;
    string model;
    int year;
};

// getSum identifier is used to call the below
// function
void getSum(int a, int b) {
    int _sum = a + b;
    cout << "The sum is: " << _sum;
}

int main() {
  
    // Identifiers used as variable names
    int studentAge = 20;
    double accountBalance = 1000.50;
    string student_Name = "Karan";

    getSum(2, 10);

    return 0;
}
Identifier Naming Conventions

Naming conventions are not the rules enforced by C++ language but are suggestions for naming variables by the programming community for easier understanding. Some of the naming conventions are as follows:

For Variables:

For Functions:

For Classes:

Once again, above are some suggestions for naming identifiers do not rule. They also depend on the project guidelines you are working on and your preferences.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4