Five forms of variable storage

Five forms of variable storage

  • From c++ Prime Plus P310
   Persistent Scope Linkability How to declare
automatic automatic Code block no In the code block
register automatic Code block no In the code block, use the keyword register
Static, no linkability Static Code block no In the code block, use the keyword static
Static, external linkability Static file External Not in any function
Static, internal linkability Static file internal No longer go to any function, use the keyword static
  • The object declared by const is the local variable of the file by default. This variable can only be in that file and cannot be accessed by other files. By specifying the const variable as extern, you can access this variable in the entire program
  • By default, the linkability of the function is external, which can be shared between files, and the keyword static can be used to set the linkability of the function to internal so that it can only be used in one file
    Insert picture description here

Guess you like

Origin blog.csdn.net/lr_shadow/article/details/108994753