Basic program of C/C + + (I.)

Source: Internet
Author: User

  1. Domain Operator: C + + supports access to global variables through domain operators, C is not supported (identify for redefinition)
  2. Efficiency analysis of ++i and i++:
    • Built-in type, no difference
    • Custom data types, ++i can return references, i++ only return object values (copy cost)
  3. Floating-point numbers and 0 judgments
    • if (x >=-epsinon | | x <= epsinon)
  4. The
  5. does not borrow the swap implementation of the intermediate variable.
    • with and
    • with XOR (same as 0, different 1)
       //  with and  void  swap (int  & A, int  &b) {a  = a + b;   b  = a- b;   A  = a- b;  //  with xor   void  swap (int  & A, int  &<   Span style= "COLOR: #000000" > b) {a  = A^B;   b  = A^B; A  = A^B;}  

       

  6. C and C + + differences
    • C implements the process Control and other functions in C + +.
    • The C part of C + + introduces overloads, inline functions, and exception handling. C + + includes object-oriented design content such as classes, inheritance, encapsulation, virtual functions, templates, package container classes, and so on.
    • Note: C + + has object-oriented features, but is not really object-oriented (Java).
  7. extern "C"
    • Use variables and functions declared within the C library. Only the header files are needed during the compile phase, and the matching definitions are found when linking.
    • Explains that internal variables or functions are compiled and linked according to the C standard to solve the name matching problem.

Basic program of C/C + + (I.)

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.