C++ variable types and the scope of variables

extern int d = 3, f = 5; // Display declaration and definition of d and f. Explain that the memory space has been opened up.

int d = 3, f = 5; // Define and initialize d and f. Define and assign (open up memory space)

extern int c;//The variable c is declared, but the memory is not opened.

The definition of c may be in other documents.

Note: The declared variable or function should be redefined when it is used.

C++'s lvalue general value specifies the expression of the memory address

The rvalue generally points to the value of the variable at the memory address.

 

The variable domain of c++ can be divided into global variables and local variables and formal parameters

Global variables are defined outside the main function

Local variables are defined in main

If both global variables and local variables are declared. See where the output is. (Can be understood as the principle of proximity)

 

 

Guess you like

Origin blog.csdn.net/zhuiyunzhugang/article/details/111474604