Lesson 2nd-Upgrading from C to C + +

Source: Internet
Author: User

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 + +

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.