Memory Models and Namespace

Source: Internet
Author: User

Continue with the C + + premier Plus

First to explain the scope and linkage, the so-called scope, refers to the scope of the variable, so-called linkage, refers to whether the variable can be shared in different files

1, Auto variable (automatic variable), local scope, no linkage

The parameters of the function, variables defined within the function (without static qualification), and variables defined in the statement block are automatic variables, with the local scope, which is the localized scope, only works in the defined function or block, and when the program executes away from a function or chunk, Where the automatic variable is freed (free) off

2, static variable (variable), three kinds of external linkage,internal linkage and no linkage

Static variables exist as long as the program is running, and will not be released. Declare a static variable of external linkage, declare it outside of all functions or chunks, declare a static variable internal linkage, precede the variable with a "static" qualifier, and a static variable to declare no linkage. Declaring a variable of type static within a block or function can

Memory Models and Namespace

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.