声明与变量定义 [英] Declaration Vs Definition of variable
本文介绍了声明与变量定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
就不同的存储类而言,变量的声明"和定义"之间有什么区别?
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
这篇关于声明与变量定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文