As I know this is a
declaration:
int
i;
and this is a
definition:
int i =
10;
May be
I am wrong I don't argue.
The
question is Does the compiler set aside memory for the declared (but not
defined) variables?
Does the
compiler set aside memory for the declared (but not defined)
variables?
No,
compiler just take a note of this variable name and type. No memory is allocated for
declaration.
int i;
can
behave as definition if i
is used (not optimized out) and href="http://ideone.com/nNy1fu" rel="nofollow">no other definition of
i
is present in any other compilation unit and storage will be
reserved for it. (because storage is reserved for definitions)
No comments:
Post a Comment