static indicates function
:1, in the function body, the value of the static variable remains constant (memory function) 2, is a local global function, that can only be accessed by the function of this module (hidden function)
static variable: The difference between a static global variable and a normal global variable: the static variable is initialized only once (that is, it cannot be defined repeatedly), which prevents the difference between a static local variable and a normal local variable being referenced in another file cell: The static variable value is initially The next operation is based on the last value (the second time the initialization statement is skipped directly) the
static function:The static function can only be valid in one source file, static in other invalid
class ofsource file: 1, regardless of the number of class objects are defined, Static data members are always only one copy, used as a share 2, static data members are stored in the global data area, when defined to allocate space, even if the class is not instantiated, static data members can be used 3, public, private, protect access 4, Static member functions are initialized outside the class (the class simply declares that it is initialized in the CPP), but at this point do not add the static keyword 5, static data members do not have the this pointer (ordinary class member functions have), so you cannot access non-static member functions in the class, only member functions can be accessed
Advantages:1, there is no global name Conflict 2, the information can be hidden, can be private note: Do not define a static variable in the header file, do not define any variables in the header file
static (static) variable of C + + Foundation