|
-
February 11th, 2008, 01:42 AM
#1
extern sample in MSDN
Hello everyone,
I think in practical experience, extern is useful only when we have more than one compile unit (cpp file) and making cross-reference between compile units.
In the MSDN extern sample,
http://msdn2.microsoft.com/en-us/library/0603949d.aspx
It only uses one source file (compile unit) to demonstrate the usage of extern, is it correct and practical?
thanks in advance,
George
-
February 11th, 2008, 02:47 AM
#2
Re: extern sample in MSDN
In the MSDN extern sample,
There are two code examples in that MSDN entry.
It only uses one source file (compile unit) to demonstrate the usage of extern, is it correct and practical?
What do you mean by "practical"? Code examples are typically not "practical", but intended either for demonstration or to be adapted for actual use.
-
February 11th, 2008, 04:28 AM
#3
Re: extern sample in MSDN
Thanks laserlight,
I mean this sample. Any comments to my original question?
Code:
// specifying_linkage1.cpp
int i = 1;
void other();
int main() {
// Reference to i, defined above:
extern int i;
}
void other() {
// Address of global i assigned to pointer variable:
static int *external_i = &i;
// i will be redefined; global i no longer visible:
// int i = 16;
}
 Originally Posted by laserlight
There are two code examples in that MSDN entry.
What do you mean by "practical"? Code examples are typically not "practical", but intended either for demonstration or to be adapted for actual use.
regards,
George
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|