Guest_imported
New member
- Jan 1, 1970
- 0
when a variable is defined as both extern and static
eg
//file1.cpp
extern int i;
static int i=30;
void main()
{
//the value is 30
}
whats the reason.
What i understand is that since the variable i is now a having internal likange. So, the linker first sees if the
variable is there in the same file in which it is defined.
As it finds it it prints that value. Otherwise it would
have searched in other files. I am not sure if this
is a correct explaination. Please help?
hawapani
eg
//file1.cpp
extern int i;
static int i=30;
void main()
{
//the value is 30
}
whats the reason.
What i understand is that since the variable i is now a having internal likange. So, the linker first sees if the
variable is there in the same file in which it is defined.
As it finds it it prints that value. Otherwise it would
have searched in other files. I am not sure if this
is a correct explaination. Please help?
hawapani