I have a namespace foo which contains an integer bar, declared so...
foo.h:
namespace foo {
    int bar;
}
Now if I include foo.h in only one file, this works just fine. But a problem arises when I  include foo.h from two or more files: I get a linker error. I figured out that if I declare bar as static, I can include foo.h in more than one file. This seems strange to me, because I wasn't aware that one could declare a static variable inside of a namespace. (what does that even mean?)
Why does this work? And more importantly, why doesn't it work without static? What does static mean when used in a namespace?
 
     
     
     
    