Declaration and Definition of Variables

The declaration of a variable is different from the definition of a variable, which is often confusing.
l The declaration of a variable tells the compiler that the variable name already exists, and the compiler recognizes the name and will not cause a compilation error.
l After the variables are defined, the compiler allocates space for the variables, and the linker can find their addresses when linking.

Declaring a variable tells the compiler that the variable name already exists, but no space has been allocated for it. That is to say, a variable is declared. If the variable is referenced in the program, it can be compiled. However, if the variable is not defined in a file, the link will go wrong, because the variable is required when linking the object file. the exact address.

Guess you like

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