您的位置:首页 > 编程语言 > C语言/C++

Relevance Between Variable Declaration and Definition in C++

2014-07-18 16:57 330 查看
A declaration makes a name known to a programm. A definition creates the assocatied entity. A variable declaration specifies the variable type and name. In addition to specifying the variable type and name, a definition also allocates storage and may provide an initial value. So in this sense, a definition is also a declaration. A variable must be defined exactly once but can be declared many times. And the difference between definition and declaration can be easilly understood by the following case.

To use the same variable in mutliple files, we must define this variable in one and only one file. Other files that use this variable must declare but not define this variable.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: