7.4--function declaration, local object, inline function

Source: Internet
Author: User

function declaration:

(1) A function must be declared before it is called, and a function can be declared multiple times and can only be called once.

(2) function return value, function name, function parameter these three constituent function prototype, function prototype describes function interface.

(3) A function declaration is provided in the header file, and the source file that defines the function needs to contain the header file.

Local objects:

(1) The names of the formal parameters and variables defined by the function are only in the scope of the function, and the names are only visible in the body of the function.

(2) Automatic objects include function parameters and local variables, and the life cycle exists only during the execution of the function.

Static local object (static)

(1) If an object is within the scope of the function, but the life cycle exists in the function's multiple invocations, this variable is often useful and should be defined as static

(2) Static local objects will not be revoked until the end of the program, once created, even if the function that defines the static local object ends.

inline function: inline

(1) The inline function avoids the overhead of the program call, which is already expanded during the compilation phase.

(2) to place the inline function in the header file, all source files that use the header file must be recompiled.

7.4--function declaration, local object, inline function

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.