"Reading Notes" C++primer---chapter II

Source: Internet
Author: User

1.c++ basic data types: Character type, integer type, floating point type, etc.;

2. The following table is the arithmetic type, the following table simply represents the minimum storage space required by C + +, but the general compiler uses more storage space than required, and the maximum value that the previous type can represent varies by machine.

Type Meaning Minimum storage space
bool Boolean type --
Char Character type 8 Guests
wchar_t Wide character type 16 Guests
Short Short-integer 16 Guests
Int Integral type 16 Guests
Long Long integer type 32 Guests
Float Single-precision floating-point type 6-digit valid digits
Double Double-precision floating-point type 10-digit valid digits
Long double Extended precision floating-point 10-digit valid digits

3. There are two types of characters, char and Wchar_t,char are generally single machine bytes, wchar_t can store Chinese and Japanese, etc., not a single byte;

4. The default type is signed, and if you need to represent an unsigned type, you must specify that the type is unsigned, such as unsigned long,unsigned int, or unsigned int if unsigned alone;

5. In C + +, assigning a value that exceeds the range of values to a type, assigning a value to the maximum value of the type, such as assigning 1 to unsigned char, the result will be 255, but there is no guarantee that all compilers are the rule;

6. Literal integer type the default is int or a long type, according to its size by default to a specific type, such as an int, the value is an int type, greater than the maximum value of int, it is a long type. By increasing the suffix, it is possible to force constant conversion of literal values to long, unsigned, or unsigned long, such as 128u for unsigned type, 1L for long type, and 1024UL for unsigned long;

7. The default decimal value is double, followed by the value of F or F for the single precision, also plus L or L for the extended precision type;

8. If l ' a ' is represented as the literal value of the wchar_t type;

9. In order to be compatible with the C language, all string literals in C + + are automatically added by the compiler to the end of a space character, and "Hello World" represents the literal value ending with a wide char;

The identifier of the 10.c++ cannot contain two consecutive underscores, or it cannot begin with an uppercase letter immediately after the underscore, and some identifiers cannot begin with an underscore;

11. Initialization means creating a variable and assigning it an initial value, whereas the assignment is to erase the current value of the object and replace it with the new value, so the initialization is not an assignment! ;

12.extern is just a declaration, not a definition, a variable must be defined only once, and a variable must be defined or declared before a variable is used;

13. When a const variable wants to be accessed by another file, it needs to add extern at the time of the Declaration, and the non-const variable defaults to extern;

14. A reference variable must be initialized at the time of definition;

15.typedef is typically used for three-medium purposes: a. In order to hide a particular type of implementation, emphasize the purpose of the use type; b. Simplify complex type definitions to make them easier to understand; c. allow a type to be used for multiple purposes while making each use of the type clear;

16. Enumeration format: Enum Open_modes {input, output, append};

17. The definition of a class includes an interface and implementation;

18. If you define a class using the class keyword, then any member defined in the first access designator money is implicitly specified as private, and if a struct is public, this is the difference between struct and class;

19. Because variables and functions need to be declared before they are used, C + + supports compiling separately, putting the declaration of functions and variables into the header file, and the implementation of the class in the CPP file;

"Reading Notes" C++primer---chapter II

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.