answersLogoWhite

0


Best Answer

In C++ we provide names for the entities we create, the variables, functions and types in our programs. These names, or identifiers, are required to conform to some simple rules.


An identifier must start with a letter and is comprised of a sequence of letters and digits. Somewhat surprisingly, in this context the underscore _ is considered to be a letter (although there are conditions associated with its use). There's no restriction on the length of an identifier.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

An identifier is a sequence of characters used to denote one of the following:

- object or variable name

- class, structure, or union name

- enumerated type name

- member of a class, structure, union, or enumeration

- function or class-member function

- typedef name

- label name

- macro name

- macro parameter

So, essentially, any time that you need to name any type of data object or function entity, the name is the identifier.

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

All legal identifiers in C++ must begin with a letter or underscore and must not clash with any reserved word other than override and final (both of which are contextual keywords). To avoid name clashes with existing identifiers, always use namespaces. A class is also a namespace, hence two classes can have the same member identifiers serving different purposes.

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

C++ identifiers follow the C convention: all identifiers must be composed of letters, digits and underscores, but cannot begin with a digit. By convention, variable identifiers are all lower case, user-defined data type identifiers have a leading capital and macro names are all uppercase. Breaking with the convention does not invalidate code, however the convention does make it much easier to differentiate what a name represents. All standard library data types are all lowercase, thus std::string is a standard library data type while String is a user-defined data type.

In addition, identifiers composed of two or more words are best separated with underscores. Programmers with a background in Pascal programming will often use "camel type" identifiers such as NameAndAddress, however a C-style name_and_addressidentifier is easier to read.

This answer is:
User Avatar

User Avatar

Wiki User

16y ago

any character in [A-Z,a-z,_] optionally followed by a sequence of any character in [0-9,A-Z,a-z,_]

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

examples: i, j, k, L12, nCount, user_control

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

those which starts with _ (underscore), a-z, or A-Z

it cannot start with numbers

it cannot use reserve words

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

None of the above. :-)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a valid c plus plus identifier?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is cin an output identifier in c plus plus?

No. In C++ with <iostream>, cin is a prefedined class that represents stdin, so it is an input identifier.


Can you pass addresses to a function in C plus plus?

If the identifier you want to pass is an ordinary identifier, pass it as the address of... function(&identifier); If the identifier you want to pass is an array identifier, pass its name... function(arrayname);


Are a10 and 10a same in C language?

No, 'a10' and '10a' are not the same in the C language. In C, identifier names must start with a letter or an underscore, so 'a10' is a valid identifier, while '10a' is not.


What is the rules to be valid identifier?

In what language?


Is A N D is an identifier?

A N D is not an identifier as it has spaces in between each letter. A valid identifier DOES NOT have space in it.


What is swap in c plus plus programming language?

It is not a reserved word, so can be an identifier (name of a type/variable/function).


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.


What is an identifier. what are the hearing rods for identifier 'c' language?

An identifier is the names given for labels, functions and variables in the c language.


What are the rules in constructing a valid identifier?

_,a-z, or A-Z


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.


Is hello is an identifier token?

Yes. The word "hello" can be an identifier token. It is not a reserved word in C or C++, and it meets the criteria for being an identifier.


What are the hearing rods for identifier 'c' language?

The hearing rods for identifier "c" language is the function.