What are the naming rules for C++ language identifiers?

coldplay.xixi
Release: 2020-06-24 18:00:54
Original
5787 people have browsed it

C The naming rules for language identifiers are: 1. The naming of identifiers should start with uppercase and lowercase letters or underscores [_]; 2. Try to name identifiers with meaningful words, etc., to increase the program’s Readability; 3. Try to capitalize the first letters of different words in the name of a variable.

What are the naming rules for C++ language identifiers?

The naming rules for C language identifiers are:

The identifier is a sequence of characters used to identify variables , functions, data types, etc. C language identifiers consist of numbers (0~9), uppercase letters (A~Z), lowercase letters (a~z) and underscores (_). The letters are case-sensitive. The following are things to note when naming:

1. The name of the identifier must start with a letter (uppercase or lowercase) or an underscore (_), and numbers cannot be used. It is not recommended to start names with an underscore, because many compilers define identifiers that start with an underscore.

2. C naming identifiers are case-sensitive. When using Hungarian nomenclature, try to capitalize the first letters of different words in the name of a variable.

3. Try to name identifiers with meaningful words to increase the readability of the program.

4. C identifiers are often used for:

1). To identify the name of an object or variable

2).Members of classes, structures and unions

3). Member function of a function or class

4) Custom type name

5). Name of the macro

6). Parameters of the macro

5. To understand Hungarian nomenclature

Recommended tutorial: "C Video Tutorial"

The above is the detailed content of What are the naming rules for C++ language identifiers?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!