Some dark dishes from C + +

Source: Internet
Author: User

The "dark dish" in this article is limited to some of the features that I feel easy to forget, interesting, and not known to most people in the process of learning C + +.

1. C + + in the type of int data in VC + + environment, the minimum value for what is-32678, rather than-32677, which involves the original code, complement, anti-code of some knowledge.

2. Precedence and binding of operators in C + +.

3. Method of coercion type conversion in C + +: 1) Double (a), 2) (int) x,3) (float) (5%3).

4. The comma and comma expressions in C + + have the lowest priority, and the value of expression 2 is the value of the entire expression.

5. Using the operator in the standard input and output stream, you need to include the Iomanip header file.

6. Functions with default parameters, the default parameters are always placed at the end of the function parameter list.

7. function overloading and function templates. Where overloaded functions require only the same function name, the parameter type/number/order has a different, the return value can be different.

8. The function's form participates in the argument, the function's formal parameter does not occupy the storage unit when defines the function, only then when the function calls, the parameter is allocated memory from the dynamic store, then after the function call ends

Release the storage unit immediately. The arguments and parameters of a function are of course not the same block of storage.

9. Arrays can omit the value of the first dimension when defined or as a function parameter, but the value of the second or higher dimension cannot be omitted.

10. Including one-dimensional, two-dimensional, multidimensional, character array, including a variety of methods to initialize initial initialization.

11. About the string end flag ' \ '. It is automatically added after the string, and the number of characters preceding it is the actual length of the string. But when there is not enough initial value, the character array will be the default array

The member is ' + ', just as the array defaults to 1 samples. When assigning an initial value to a character array with a string, be careful to make an error (the array length is not enough) because of the ' \ s ' reason. The character array can finally be not '. '

12. On the issue of handling strings, C: String constants, character arrays, string handling functions.

C++:string class.

13. In VC + + environment, a char data accounted for one byte, an int data accounted for two bytes, a float type of data accounted for 4 bytes, a double type data accounted for 8 bytes.

14. In VC + + environment, allocate 4 bytes of storage space for each pointer variable, regardless of the type it points to.

In C + +, the transfer value and the address: the classic swap function, the wrong wording is only the value of the formal parameter exchange, the value of the actual parameter does not change, the correct use of pointers in the notation, the parameter is a pointer variable, directly modify

The value of the corresponding storage unit. Both of these methods belong to the method of passing values.

The correct way to use references is in C + +.

16. The common body and enumeration.

PS: not updated regularly.

Some dark dishes from 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.