static keyword

The static keyword has at least the following effects:

(1) The scope of the static variable in the function body is the function body. Unlike the auto variable, the memory of the variable is only allocated once, so its value still maintains the last value when it is called next time;

(2) Static global variables in a module can be accessed by functions used in the module, but cannot be accessed by other functions outside the module; (using namespaces need to be used in other modules)

(3) A static function in a module can only be called by other functions in this module, and the scope of use of this function is limited to the module in which it is declared;

(4) The static member variables in the class belong to the entire class, and there is only one copy of all objects of the class;

( 5) The static member function in the class belongs to the entire class. This function does not receive the this pointer, so it can only access the static member variables of the class.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324803989&siteId=291194637