Relevance Between Variable Declaration and Definition in C++

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.

Relevance Between Variable Declaration and Definition in C++,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。