Re: extern variable assignment
- From: George <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 06:42:03 -0800
Thanks Igor,
extern int i = 3;
1. Is it correct?
Yes, though keyword 'extern' serves no useful purpose here.
If it is both a declaration and a definition, does it violates the MSDN
extern documents -- which extern is used for declaration?
http://msdn2.microsoft.com/en-us/library/0603949d.aspx
--------------------
The extern keyword declares a variable or function and specifies that it has
external linkage (its name is visible from files other than the one in which
it's defined).
--------------------
regards,
George
"Igor Tandetnik" wrote:
"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message.
news:414B7395-BA16-4826-86AC-109D4FA40586@xxxxxxxxxxxxx
Statement like this,
extern int i = 3;
1. Is it correct?
Yes, though keyword 'extern' serves no useful purpose here.
2. Is it definition or declaration?
Both.
Any special function or benefits
we could get compared with
extern int i;
This is a declaration but not a definition.
int i = 3;
This is the same as "extern int i = 3;" if the statement appears at
namespace scope. When in block scope, this statement defines a local
variable while the original statement is illegal.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
- Follow-Ups:
- Re: extern variable assignment
- From: Igor Tandetnik
- Re: extern variable assignment
- References:
- extern variable assignment
- From: George
- Re: extern variable assignment
- From: Igor Tandetnik
- extern variable assignment
- Prev by Date: Re: Returning Char array/pointer? Continuing of thread I am confused with these concepts.
- Next by Date: Re: type safe issue
- Previous by thread: Re: extern variable assignment
- Next by thread: Re: extern variable assignment
- Index(es):
Relevant Pages
|