static and extern keywords

I am confused in static and extern keywords
When we declare static variable i in one file a.cpp

and then use extern THAT VARIABLE i in b.cpp
than what operations can we perform on i in b.cpp

1.Can we directly use that value of i?


2.can we declare declare new variable with same name?

Any other you want to sepcify in this context would heplp me


Thanks
Last edited on
FileA.cpp
1
2
3
4
5
#include <iostream>

static int i; // This variable restricted to use in fileA.cpp only

//other code 



FileB.cpp
1
2
3
4
5
#include <iostream>

extern int i; // This is NOT the variable i from FileA.cpp  

//other code 
Topic archived. No new replies allowed.