[Chaohuaxixi] What is the use of static? (Please specify at least two)

Topic: What is the use of static? (Please specify at least two)

Reference answer:

  1. In the body of the function, a variable declared as static maintains its value during the process of the function being called.
  2. In the module (but outside the function), a variable declared as static can be accessed by the functions used in the module, but cannot be accessed by other functions outside the module. It is a local global variable.
  3. Within a module, a function declared as static can only be called by other functions in this module. That is, this function is restricted to be used in the local scope of the module in which it is declared

Guess you like

Origin blog.csdn.net/qq_36045898/article/details/114027540