1: Please tell me what is the advantage of the const compared with #define.
Answer:
Const action: Define constants, modifier function parameters, cosmetic function return value three functions. The things that are modified by the const are
Static C language
The C language program can be seen as a series of external objects, which may be variables or functions. The internal variable refers to the function parameters and variables defined within the function. External variables are
Static
A static data type is used to create a permanent storage space for a variable. The statically variable keeps their values unchanged when invoked between functions. When used in a class, all the variables that are used in a static variable
Original: http://www.cnblogs.com/chenglei/archive/2009/09/06/1561367.html
Viewing from scopes:
Global variables have global scope. Global variables can be used for all source files only if they are defined in one source file. Of course, other
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
The role of Static
1. HideWhen we compile multiple files, all global variables and functions that do not have a static prefix are globally visible and other source files can be accessed. For example, we have the source file Source1.cpp
1. C language variables are mainly divided into global variables, static global variables, local variables, static local variables and register variables. Where static variables are decorated with the static keyword. The memory that the program
Overview
Basically every language has to discuss this topic, C is no exception, because only you fully understand each variable or function storage mode, scope and destruction time to correctly use the language. Today, we will focus on the scope,
(1) What is the difference between a static global variable and a normal global variable?(2) What is the difference between static local variable and ordinary local variable?(3) What is the difference between the static function and the normal
1.exit (0) Normal exit procedure
Exit (1) program exception exits program
2.static (static variable) modifies local variables
Using static adornments in local variables prolongs the lifetime of local variables. But we need to pay attention to a
Thread-Safe single case modeLazy mode : That is, the first time the class instance is invoked, a new instance of that class is generated, and only this instance is returned at a later time.
Locks are required to ensure thread safety: Reason:
1 Static keyword1.1 HiddenegIn the A.C filechar a = ' a ';void msg (){printf ("hello\n");}In the Main.c fileextern char A;printf ("%c", a);Output Result: A Helloall global variables and functions that do not have a static prefix have global
The local variables of the program exist in (the stack), the global variables exist in the (static zone), and the dynamic requisition data exists in the (heap).1. Acting on a variable:Declare a local variable with static-------local variable refers
Static
Declared variables have two features in the C language:
1) The variables will be placed in the global storage area of the program, so that the original values can be maintained during the next call. This is the difference between stack
I just started to learn to write some C ++ programs. I don't understand many problems. When you look at the big bull program, you can't keep up with your ideas. Many things need to accumulate slowly. Therefore, write down some knowledge points for
Highlight:
1. Variables
2. Distribution of C Programs in memory
3. Modify the keyword of a Variable
1. Variables
----> Local variables
Lifecycle: from definition to function completion
Scope: Within the function that defines this local variable
----
1. Overview
Static declared variables have two features in the C language:
1) The variables will be placed in the global storage area of the program, so that the original values can be maintained during the next call. This is the difference between
1. static variable
The type description of static variables is static. Static variables belong to static storage, but not necessarily static variables. For example, an external variable is a static storage method, but not necessarily a static
Original Digest from: http://www.cppblog.com/shifan3/archive/2007/01/05/17325.htmlDetailed linkSome people write C + + (the following is assumed to be C + +) program, unresolved external link or duplicated external simbol error message at a loss
If static is a static variable in PHP, and he can define a function, and the variable is a global static variable, then how do we add static to the function or variable that will affect the functions and variables, let's look at it together.
1)
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.