Chapter 2: variables and Basic Types

Source: Internet
Author: User

1: Int Is the machine length, short is half, and long is one or two. The default nominal value is int, and the excess value is long. Long is much larger than Int.

2: Float Type 6 precision, double has about 10, the cost is not that big, so the default value in the program is double.

3: The numeric suffix, u can only be on the integer type, and the integer type cannot use the floating-point suffix such as f or D. Similarly, the floating-point type cannot use the U integer; but l, E is public

4: only the built-in types of the literal value are available. In special cases, the string type is also available. \ 0 is automatically added. This value can be measured using sizeof. The literal value is the prefix.

5: initialization, replication initialization efficiency is lower than direct initialization.

6: The backslash can separate the code by line breaks, and there cannot be blank spaces and Tab keys behind the backslash.

7: line breaks are equivalent to spaces.

8: system initialization. The function is initialized to 0 in vitro and not in vivo.

9: constants cannot be modified and must be initialized.

10: constants do not contain extern by default, rather than Const. Therefore, the const volume only belongs to the current file volume. If it is used for other purposes, it must be indicated with extern.

11: In a reference, a const reference can be bound to a different but similar type object or a nominal value. A non-const reference can only be an object of the same type. Const can reference a non-const volume, rather than a const volume.

12: typedef is similar

13: enumeration is used to map the value to the name of the object, and make the value meaningful. Add a semicolon after curly braces;

14: class type. Pay attention to the plus points in curly brackets for definition;

15: The difference between class and struct is that the default access permission is different. The default access permission of class is private and that of struct is public.

16: the header file is used for declaration and cannot be defined in it. In case of processing 3, 1 is the class definition, 2 is the const definition and initialized with a constant expression, and 3 is the inline function.

17: the header file is designed to put the logic together for easy code reading and use.

18: multiple source files reference the same header file, which may cause multiple inclusion of the header file. This result is re-defined. The solution is to avoid using preprocessing variables.

The mode is as follows:

# Ifndef xxxx_h

# Define xxxx_h

# Include "myfile. H"

# Endif

19: Use System header files <>; Use "" for your own header files. The difference is that you can find files from the system directory and find files from the local directory.

Chapter 2: variables and Basic Types

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.