Storage categories for C + + variables (dynamic storage, static storage, automatic variables, register variables, external variables)dynamic storage mode and static storage mode
We've learned about the scope of variables. Scopes are analyzed from
Static life cycle 2011-07-15 16:01
The type descriptor for a static variable is static. Static variables, of course, are static storage, but the amount of static storage is not necessarily static variables, such as external variables are static
Static in C + + has two uses for the use of static for C + +: Static in process-oriented programming and in object-oriented programming. The former applies to ordinary variables and functions, and does not involve classes; the latter mainly
Memory allocation of a program
The memory consumed by a program compiled by C + + is divided into the following sections:
1, stack area (stack)-by the compiler automatically assigned to release, store the function of the parameter values, local
The static of C + + has two usages: static in process-oriented programming and static in Object-oriented Programming. The former applies to ordinary variables and functions, and does not involve classes; the latter mainly describes the role of
------- iOS Training look forward to communicating with you! ----------First, variablesA variable represents a named storage unit with a specific attribute, and the value of the variable can be changed during operation. variables must be defined
The static of C + + has two usages: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables and functions, and does not involve classes; the latter mainly describes the role of
Global variablesScope: Global scope (global variables can be used for all source files only if they are defined in one source file.) )Life cycle: Program run time is always presentReference method: The global variable to be referenced must be
Variables can be divided into global variables, static global variables, local variables, and static local variablesThere are two scenarios for declaring a variable:1. One is the need to create a storage space (a declaration of definition). For
Third, static variables
The type descriptor for a static variable is static. Static variables are, of course, static storage, but the amount of static storage is not necessarily static variables, such as external variables are static storage mode,
1. Sometimes returning a reference can improve the efficiency. In some cases, a reference cannot be returned.
In the class assignment operator function, the reference of the returned object can significantly improve the efficiency.
Class String {
C ++ (4): variables and variables
Local variable
Variables defined in a function are internal variables, which are valid only within the scope of the function. That is to say, they can only be used in this function, and cannot be used outside of
Transferred from: http://www.cnblogs.com/lzjsky/archive/2010/11/19/1882064.htmlA static global variable is formed by the description of the global variable (external variable), preceded by static. Global variables themselves are static storage, and
Turn from DZQABC large static variable understandingThe static variable type descriptor is static.Static variables are static storage, where the storage space is a static data area in memory (a storage unit is allocated in a static store), and the
A static global variable is formed by the description of the global variable (external variable), preceded by static. Global variables themselves are static storage, and static global variables are, of course, static storage methods. The two are not
Static is a common keyword in C + + that is used to control how variables are stored and visible.In a class definition, its members, including data members and member functions, can be declared as static members with the keyword static. The
1. The purpose of the singleton mode is to ensure that a class has only one instance. 2. Principle (1) Private Static pointer variable implementation: Use the Private Static pointer variable of the class to point to the unique instance of the class
The difference between a static variable and a global, local variableA static global variable is formed by the description of the global variable (external variable), preceded by static. Global variables themselves are static storage, and static
The 1.c/c++ variable has different scopes according to the different life cycles of the defined positions, and the scope can be divided into 6 types:Global scopes, local scopes, statement scopes, class scopes, namespace scopes, and file scopes.From
Auto ordinary local stack variable: is automatic storage, the limit variable can only be used inside the function, this object is automatically created and destroyed, it is recommended that the variable is placed on the stack, the function is called
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.