C + + and C's specifications differ

Source: Internet
Author: User

C + + and C's specifications differ

1. After each class declaration, add a line of space after the end of each function definition.

2, in a function body, logically closely related statements can not be blank lines, and logically differentiated between the paragraphs must be blank lines.

3, unary operators such as "! "," ~ "," + + ","--"," & "(address operator) should be preceded by a space.

4. The maximum length of the code line cannot exceed 80 characters.

5, modifier near data type and variable name.

6, the C language annotation is "/*......*/", in C + + language, the program block annotation often uses "/*....*/", the line annotation generally uses "//...".

7. Some abbreviations that almost form customary usage should be followed as much as possible. For example: Addr (d address), Pnt (Point), Memo (Memo), Cur (current), and so on.

8, the length of the identifier should conform to the "Min-length && max-information" principle.

9. Although C + + now supports long identifier names, it is still possible to design short and valid identifiers as far as practicable.

10, naming rules as far as possible with the operating system or development tools to maintain the same style.

11, the variable name should use "noun" or "adjective + noun".

12, the name of the global function should use "verb" or "verb + noun" (moving the phrase). The member function of a class should use "verb" whenever possible, and the omitted noun is the object itself.

13. Use the correct antonym group to name a variable with mutually exclusive meaning or a function of the opposite action.

14. Class name and function name are combined with words beginning with capital letters.

15. When naming variable names, you should include the shorthand of their type. The specific shorthand table is as follows. If the class member variable is named M_b**,m_ty,m_w**,m_dw and so on, the general temporary variable is named b**,i**,dw** etc.

Abbreviated data type (both lowercase)

BOOL b

Byte by

Word W

DWord DW

Int I

Double D

Long L

Short N

Float F

Char C

csting s

Array A

Pointer P

Kntime T

Handle Type H

Colorrer CR

Point PT

Window Windows Type Wnd

Unsigned Long UN

Rect R

16. Static variable plus prefix S_ (indicates static).

17. If a global variable is required, prefix the global variable with g_ (representing global).

18. The data member of the class is prefixed with m_ (representing member), which avoids confusion between the data member and the variable name of the member function.

19, in order to prevent some of the software library identifier and other software library conflicts, the various identifiers can be added to reflect the nature of the former software. For example, all library functions for the three-dimensional graphics standard OpenGL begin with GL, and all constants (or macro definitions) begin with GL.

C + + and C's specifications differ

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.