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