Why can't i just define a non-const gloabal variable in header? and if i use namespaces why do i have to declare it 'extern'? : 1) I know a non-const variable is external linkage by default (it's like it's been declared as external more or less) but i dont understand why cant i define a global variable such as `int glbl_a` in header 

    //test.h

	int glbl_a=0;	//wrong -> "multiple definition of `glbl_a`"	
	static int st_glbl_a=1;	//ok to initialize it in header!
	extern int ext_glbl_a; //ok to declare it and define it in test.cpp
	
---------
    //test.cpp

    #include "test.h"
    using namespace std;

	//st_glbl_a=22;	i could use st_glbl_a but it wouldn't affect st_glbl_a in main cause of 'static'	
	int ext_glbl_a=2; //definition of external gloabal non-const variable

-----------------
    //main.cpp
    
    #include <iostream>
    #include "test.h"
    using namespace std;
     
    extern int glbl_a; //declaration of glbl_a external
    int main(){
     cout<<glbl_a;
    }

the working version for this program is the one in which i define `int glbl_a=0;` in test.cpp only and declare `extern int glbl_a;` in main before using it in output (definition in test.h is just commented, that is there's nothing about `glbl_a`).

2)the working version doesn't work anymore if i group all definitions/declaretions into a namespace spread onto test.cpp and test.h (`MyNamespace`) cause of `int glbl_a` in test.cpp:

    //test.h
    namespace MyNamespace{
    //extern int glbl_a;
    }

---------
    //test.cpp

    #include "test.h"
    using namespace std;
    namespace MyNamespace{
     int glbl_a=0;
    }

-----------------
    //main.cpp
    
    #include <iostream>
    #include "test.h"
    using namespace std;

    int main(){
     cout<<MyNamespace::glbl_a; //wrong -> "'glbl_a' is not a member of 'MyNaspace'"
    }
    

it would work only if i de-comment declaration in test.h, but why?