Hi
Wanted to explain the later part of the quesiton when there are two static variables with the same name in two files then what would happen?
To be clear lets undertand what the term static means in various scenarios
(I)When a local variable is made static in a function it can be initialized only once and it exists thru out to scope of the function.
(II)If a global variable or a function is made static it means that that particular variable/function is local to that file.(If u try to access that variable/function from other file using the word extern it would result in an error).
(III)The static variables declared inside a class is the third type.
As the (II) explains clearly the static variable is local to that file. So though there exists a staic variable with the same name it doesnt matter.