What does “using namespace” do exactly?
问题 The following C++ test code does not link (gcc 4.9.2, binutils 2.25). The error is In function 'main': undefined reference to 'X::test' . 01: #include <string> 02: #include <iostream> 03: 04: namespace X 05: { 06: extern std::string test; 07: }; 08: 09: using namespace X; 10: std::string test = "Test"; 11: 12: int main() 13: { 14: std::cout << X::test << std::endl; 15: } Because of line 09, I was expecting line 10 to define the X::test variable declared on line 06. I believe that instead an