[C ++] Static global variables/global variables, static functions/common functions, static variables in functions/variables in functions, static member variables in classes/common class member variables

Source: Internet
Author: User

Http://blog.csdn.net/duckur/archive/2005/11/05/523545.aspx

Static global variable: File Scope: valid only in the declared file, invisible to other source files; with a static Lifecycle
Global variable: File Scope: extern can be added to declare as an external variable, cross-File Scope

Static (global) function: has a file scope and is only used in this file.
Global function: No File Scope

Static member (in function) variable: After the function is called, the variable is saved and called again. No space is allocated.
Member (in funcition) variable: life cycle in the function

Static member (in class) variable: belongs to the class range,
Member (in class) variable: belongs to a specific object derived from the class, with the same lifecycle as the object

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.