1.1. Contents
1.1.1Variable:
(1) Types: bool, char, int, long, longlong, float, double, long double.
(2) Range: 1 byte = 8 bits. - 1 bit, 7bits, 4 bytes, 4 bytes, 8 bytes, 4 bytes, 8 bytes, 8 bytes.
(3) unsigned: the unsigned version is usedfor taking the absolute value of a signed variable. It prevents the overflow.
(4) Initial value: for global/staticvariables, they are zero; for local ones, they are 0xccc (debug mode)/ a randomvalue (release mode).
(5) local/static/global: (Very important!)
(5.1)local variable: defined locally (isonly visible to certain functions, usu in a pair of curly braces); its valuestored in the stack of this function (i.e., the stack of this thread);disappear (its value will not be recovered) when the functioin ends; it hides a global variable of the same name(use scope resolution operator to distinguish them).
(5.2)global variable: defined globally(outside of any function, i.e. out of any pair of curly braces); local to thefile define them, and use extern to declare them in another file where they areused; they are initialized to be zero; they are stored in the global/staticstorage area (i.e., are visible to all threads of one process); will disappearwhen the program ends (i.e., the process terminates).
(5.3)static variable: has types ofvariables: local and global; combine the features of local and globalvariables; static local is only visible to the function where to declare themand initialized to be zero if not specific; static variable is stored in theglobal/static storage area, but they are not visible to other functions (i.e.,threads); their value will not disappear when the function ends (i.e., theirvalues will be same as that when the function ends, then they are used forrecord the system status, e.g., thetimes a function is called); static global variables are only visible tothefunctions declared in this file (i.e., cannot use extern to refer them inanother file, then from thisperspective, static and global are anonymous); static variable is used for decrease the coupling of functions anddependency on global variables (this can also simplify the design ofinterface).
(6)define/declare/refer:
(6.1)declare: set a name can be used byother variables or functions in the current file.
(6.2)define: declare and initialize avariable.
(6.3)refer: declare a variable which isdefined in some oth