Best Answer

Identifier Definition: A name associated with a function or data object and used to refer to that function or data object.

An identifier is a name which will be used to describe functions, constants, variables, and other items.

The rules for writing identifiers in C++ are:
Identifiers must begin with a letter or underscore.
Only letters(A-Z,a-z), digits(0-9), or underscore( _ ) may follow the initial letter.

Ex: sum_of_squares, box_22A, GetData, count---valid
The blank space cannot be used.

Ex: Get Data cannot be an identifier as blanks are not allowed in identifiers
Identifiers cannot be reserved words. Reserved words or keywords are identifiers reserved for system use.

Ex: int......cannot be an identifier as it is a reserved word in C++
Identifiers beginning with an underscore have special meaning in some C++ systems, so it is best not to start your identtifiers with an underscore.
Most C++ compilers will recognize the first 32 characters in an identifier. Also, C++ is a case sensitive language. C++ will distinguish between upper and lower case letters in identifiers. Therefore:
grade and Grade are different identifiers
A good identifier should also be a mnemonic device which helps describe the nature or purpose of that function or variable. It is better to use grade instead of g, temperature instead of t.
However, avoid excessively long or "cute" identifiers such as:

gradePointAverage or bigHugeUglyNumber

Remember that our goal is to write code which is easy to read and professional in nature.
Programmers will adopt different styles of using upper and lower case letters in writing identifiers. The reserved keywords in C++ must be typed in lower case text, but identifiers can be typed using any combination of upper and lower case letters.
You can develop your own conventions like below:
A single word identifier will be written in lower case only.
Examples: grade, number, sum.

If an identifier is made up of several words, the first letter will be lower case. Subsequent words will begin with upper case.
Some examples are: stringType, passingScore, largestNum.
Identifiers used as constants are often fully capitalized.
Examples: PI, MAXSTRLEN.
User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the rules for constructing a C plus plus identifiers?
Write your answer...
Still have questions?
magnify glass
Related questions

Is it possible to declare a keyword as an identifier in c plus plus?

No. Keywords are reserved and cannot be used as identifiers. However, C/C++ is case-sensitive. So although register is a reserved keyword, Register is not.

2 types of identifiers in C programming language?

1. identifiers beginning with a letter 2. identifiers beginning with an underscore

What is the identifiers in turbo c?

all keywords

Is the identifiers 'name' and 'NAME' different in c?

Yes they is different, C language are case-sensitive.

What are the different WM words that can be used in C plus plus projects?

WM_* identifiers are Windows Message Codes defined in windows.h. They really have nothing special to do with C++ projects, as they are a function of an implementation library. There are more than several hundred different message codes.

What are the balance identifiers for disbursement accounting?

C, o, u, e

Why do you need variable declaration in c?

Because, by the rules of the language, all identifiers must be declared before or during initialization (and use). The only exception is that untyped functions are assumed to return an int. These are the C rules. For the C++ rules, it is the same, except that functions must also be declared. The technical reason why is simply that the compiler is designed to be a single pass compiler, and that only works when you know the a priori type of an identifier.

What are the balance identifiers for disbursement accounting stages?

C, o, u, e

A program that executes in c but not in c plus plus?

The logic to create such programs is very simple. We know that rules of programming languages. Among them the most important one is "We should not use keywords as identifiers". Based on this rule we can create many programs that execute in c but not in cpp. Suppose write a program to and two numbers. Store the two values in two variables, name the variables as class and object. then execute in c. it will produce the output, and do the same thing in cpp, it will give two errors. because we used keywords as identifiers in cpp. ex:-#include<stdio.h> #include<conio.h> void main() { int class=10,object=26,res; res=class+object; printf("%d",res); getch(); } Or: char str3[3] = "ABC"; /* doesn't compile in C */

Can a reserved word be used as an identifier name?

Identifiers are a bit more generic in the context of programming. If you mean, in terms of the C languages (C, C++, C#), the question is the reverse...keywords may NOT be used as identifiers. For example, you cannot use keywords such as "int", "float", "double", etc. as the names of variables or objects.

How are the graphs of functions defined by rules like y equals ax plus bx different from those of functions with rules like y equals ax plus c?

The graph of the first form passes through the origin while the second does not - unless c = 0.

How do you write in c plus plus plus plus a number followed by a letter?

If you're asking how to create an identifier that begins with a number, then the answer is you cannot. All identifiers must begin with a letter or an underscore. If we allowed leading numbers, the compiler wouldn't be able to distinguish whether 42 was an identifier or a numeric value. Whereas _42 is clearly an identifier.