C + + Personal Memo

Source: Internet
Author: User

  Resources:

1. C + + Programming ideas (Volume I)

  

  Knowledge Points:

Register Variable : It is a type of local variable. It tells the compiler to access the variable as soon as possible. Variables are generally placed in registers, but not guaranteed. The address of the register variable cannot be obtained or computed, and the register variable must be declared in the module. No global or static register variables.

  Note: to trust the compiler, try to avoid using the Register keyword.

static Variable: The ① method is initialized at the first call of the method, and the value of the static variable (memory effect) is saved at a later method call.

② when a static method or variable is outside all methods, it means that the variable can be accessed only in that file. It is also said that its scope is the file, even if the extern keyword is added.

extern keyword : the extern keyword tells the compiler that the variable or method exists, although it is not seen in the currently compiled file. The variable or method may actually be defined in another file or in the context of the current file. Again,extern and static cannot coexist.

The const keyword : The const modifier is telling the compiler I "it will never be changed." Read-only Registers

The volatile keyword : the volatile modifier tells the compiler that "you never know when it will change" and prevents the compiler from making optimizations based on the stability of the variable. Mainly in the multi-threaded environment. Forced to read, forced to write, thus ensuring the consistency of data.

internal links internal linkage and external links external linkage.

  

C + + Personal Memo

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.