Global and local name collision
Given the following source code
How your compiler will differentiate between global and local variable when they have same name.However answer to this question is compiler dependent but you can give your answer according to compiler you use.
static int a_static_var = 5;
void foo(void)
{
static int a_static_var = 6;
return;
}
How your compiler will differentiate between global and local variable when they have same name.However answer to this question is compiler dependent but you can give your answer according to compiler you use.
In C++, using the scope resolution operator ::
ReplyDeleteIn C, conflict is resolved in favour of local variable always.
@jainendra but if you want to use global variable somewhere outside foo() ,then how compiler differentiate between them.Basically this is resolved using name mangling..
ReplyDelete