9.8 C + + Learning Summary 2

Source: Internet
Author: User

After a few days of learning began to gradually touch the relative importance of C + + parts.

1, inline functions and function overloading

inline function: +inline before function

When this function is used, the code is embedded directly into the current position, mainly to avoid the function taking too much time in the process of calling the function.

Therefore, the inline function should be: 1, short, 2, often called. So that we can realize the value

Functions are overloaded, and functions are loaded automatically based on the invocation, mainly for functions with the same function name.

Note how you can make a function overload.

2. Basic design principle of function

This is more about methodology, and more practice in practice.

1, the function declares the design principle, mainly regarding the name, the entry parameter, returns the argument. This is basically a note.

2. The body design of the function

1. In the "entrance" of the function body, the validity of the parameters is checked 2, the function return value 1 is handled cautiously. The function should be clear and 12. The code of the function should be short and lean 3. The function should avoid nesting levels too many 4. function should avoid repeating code

9.8 C + + Learning Summary 2

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.