声明与变量定义

声明与变量定义

问题描述:

就不同的存储类而言,变量的声明"和定义"之间有什么区别?

What is the difference between the "Declaration" and "Definition" of variables in terms of different storage class?

有关解释,请看这里:
http://en.wikipedia.org/wiki/External_variable [
—SA
For explanation, look here:
http://en.wikipedia.org/wiki/External_variable[^].

For a sample, locate the section "Example (C programming language)"; file1 — definition; file2 — declaration. Usually declaration is used in *.h file, so there are many repetitions of the text of the same declaration in the same project, but the definition should be only one (otherwise the symbolic linker won''t be able to resolve which one to use), so the definition is placed only once in some *.C file.

—SA