Zookeeper
1. Four areas of memory
2. In the program, the variable declaration can have multiple copies, and the definition can only have one copy.
3. The register is in the CPU and there is no address.
4. C language Embedded Assembly Language
5.
[C ++ medium]
In. h:
Class C
{Public:
Static int A [2]; // Initialization is not allowed here
};
Note the following when initializing :,
1. if it is placed in. H, you need to avoid duplication. You can use preprocessing:
# Ifndef init
#
Storage of variables in C
1. If the local variables in the function are not specifically described, they are all auto, that is, they are dynamically stored, and auto can be omitted. A local variable can also be defined as static, and its value in
For example:
Class {
Public $ F1 = 'xxxx ';
Static public $ f2= 100;
}
If you want to assign a variable to an object, you can only initialize the variable in the constructor. For example:Class {Private $ child;Public Function _ construct (){$
Static a variable declared as static remains unchanged when the function is called.
What does this sentence mean? Obviously, static declared variables can be changed?
C/C ++ code
Void fun1 () {static int Var = 40; printf ("var1 = %
The initialization process of static variables of the class is clear, and Initialization is performed outside the class.
The initialization of static variables in the template is also the same, but it is somewhat complicated to write.
Template
When multiple
ProgramWhen using the same shared library, we all know that multiple programs have multiple processes, but the shared library has only one copy in the memory. So the question is: If I define a global variable in the Shared Library, is
"+" Of Object-C is similar to static functions in C ++. It can access variables declared by static. Example:
1. Code:
// Classa. h
# Import
Static int count;
@ Interface classa: nsobject
+ (INT) initcount;+ (Void) initialize;@ End
/// Classa. m
#
Class test{ Public static function (){}Public function B (){}} $ Obj = new test;Call codeTest: ();$ Obj-> ();$ Obj-> B (); Example: an example of static variablesClass myobject {Public static $ mystaticvar = 0;Function mymethod (){//: A
Initialization Order of the one class (no inheritance condition)Rules:1. Static variables > General variables > Construction methods 2. The order in which variables are defined determines the order in which they are initialized3. Static variables
Directly on the codePB = ++self:: $pa; }} $a = new example; $b = new Example;echo $a->pb;echo ' '; echo $b->PB;? >It was supposed to be the result.1-----------------------------------------------------1But I was wrong and the right result was1---
All global variables and functions without the static prefix have global visibility. I will give an example to illustrate this sentence.Static is initialized to 0 by default. In fact, global variables also have this attribute, because global
The examples in this article describe the use of static variables in C # classes. Share to everyone for your reference. The specific analysis is as follows:Take a look at the code first: The code is as follows:Using System; Namespace Param { Class
The definition of static member variables consists of two parts.
Like a function, you must first declare it in the class, and then find another place to implement it. Static members must first declare it in the class, and then "IMPLEMENT" outside
Static: I. Control Storage Methods: Static is introduced to inform the compiler that the variables are stored inProgramInstead of stack space. 1. Cause: when the program executes the variable defined in the function to its definition, the
Today, I added a static member variable when writing a static library. I didn't expect it to cause lnk2001: an error of external symbols that cannot be parsed.
Internet Lookup, which needs to be defined separately
Just define it in the CPP file.
In C language, you can use the static keyword in the global scope: variable or function modified by the static keyword, only in this ". c file "is visible, while in other ". file C is invisible. For example, if the static function func is defined in
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.