What is difference between "data definition" and "data declaration"?
data definition and data declaration
Collapse
X
-
A declaration establishes the names and characteristics of data objects used in a program. A definition allocates storage for data objects, and associates an identifier with that object. When you declare or define a type, no storage is allocated...
for more info check
http://publib.boulder. ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic =/com.ibm.xlcpp8l .doc/language/ref/data_dec.htm -
Not true.Originally posted by kittu513When you declare or define a type, no storage is allocated...
When you declare a type no storage is allocated.
When you define a type, then storage is allocated.
You said it yourself in the previous sentence and then seemed to contradict yourself. Probable just a typo but I wanted to be sure the OP was not misled.Comment
-
Thanks 4 that.Originally posted by weaknessforcatsNot true.
When you declare a type no storage is allocated.
When you define a type, then storage is allocated.
You said it yourself in the previous sentence and then seemed to contradict yourself. Probable just a typo but I wanted to be sure the OP was not misled.
but can u plz give me exp like
int a=0;
this is included in definition right and
int a;
this is a declaration that ur identifier is of integer type?Comment
-
int a = 0; is a definition. Memory is allocated. The value of the int is 0.Originally posted by jimhakansbut can u plz give me exp like
int a=0;
this is included in definition right and
int a;
this is a declaration that ur identifier is of integer type?
int a; is a definiton. Memory is allocated. The value of the int is garbage.
A declaration of than integer requires that no memory be allocated. The only way that can happen is if the int is in some other source file. In that case you can declare an int:
extern int a;
The compiler will report the int as an unresolved external reference. This will cause the linker to go find the int and connect it to the code in this source file.Comment
Comment