Lesson 2nd-Upgrading from C to C + + 1. C and C + + relationships
(1) C + + inherits all C features
(2) C + + provides more syntax and features on the basis of
(3) C + + Design goal is the operation efficiency and the development efficiency unification
2. C-to-C + + upgrade
(1) C + + More emphasis on the practicality of language, all variables can be used when the need to define.
Comparison: Variables in the C language must be defined at the beginning of the scope
(2) The Register in C + + is only a compatible function.
-register keywords
① background: When using local variables, the code snippet first puts the variables in the stack memory into the general registers of the CPU. For variables with high read-write frequency, this approach is inefficient.
② function: The Register of keywords registers requests the compiler to have variables in the register of CPUs as much as possible .
③ Note: (Refer to the blog: Analysis of C register keywords)
Register in the-c++
①
3. Summary
(1) C + + more emphasis on practicality , you can declare the variable in any place
(2) Register in C + + is only a compatible function
(3) C + + compiler to better optimize
(4) The specified type must be displayed for any identifier in C + +
Lesson 2nd-Upgrading from C to C + +