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.
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.
相关文章推荐
- What are the differences between a pointer variable and a reference variable in C++?
- Difference between pointer variable and reference variable in C++
- what is the difference between definition and declaration in c
- what is the difference between definition and declaration in c
- What are the differences between a pointer variable and a reference variable in C++?
- What is the difference between a definition and a declaration?
- Difference Between Initialization and Assignment in C++
- The differences between pointer and reference in C++
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
- What exactly is the difference between “pass by reference” in C and in C++?
- Difference Between Vector and Deque in C++
- Distinguish between pointers and references in C++
- What are the differences between struct and class in C++?
- Convertion between string and int in C++
- keywords between managed c++ and c# in dotNet 2.0
- what is the difference between static and normal variables in c++
- The different between Char in C#.Net and in C++.Net(MFC)
- The differences between new(delete) and malloc(free) in c/c++
- How to separate the implementation and definition for template function in c++
- socket communication between a Java and/or C++ programs (现成的程序)