title: Using same namespace in C++ for two classes declared and defined in separate files
body: <p>I am trying to declare two classes <em>C1</em> and <em>C2</em> in files <em>nstest1.h</em> and <em>nstest2.h</em> which are defined in files <em>nstest1.cpp</em> and <em>nstest2.cpp</em> respectively. Both the classes are defined under same namespace.</p>
  
  <p>Following are the files :</p>
  
  <pre><code>//nstest1.h
  namespace Mine{
      class C1{
          public:
          void callme();
      };
  }
  
  //nstest2.h
  namespace Mine {
      class C2 {
          public:
              void callme();
      };
  }
  
  //nstest1.cpp
  #include&lt;iostream&gt;
  #include "nstest1.h"
  
  using namespace std;
  using namespace Mine;
  
  void Mine::C1::callme(){
      std::cout &lt;&lt; "Please call me " &lt;&lt; std::endl;
  }
  
  //nstest2.cpp
  #include&lt;iostream&gt;
  #include "nstest2.h"
  
  using namespace std;
  using namespace Mine;
  
  void Mine::C2::callme(){
      std::cout &lt;&lt; "Please call me too" &lt;&lt; std::endl ;
  }
  </code></pre>
  
  <p>Following file tries to use this classes using namespace <em>Mine</em>.</p>
  
  <pre><code>//nstest.cpp
  #include&lt;iostream&gt;
  #include "nstest1.h"
  #include "nstest2.h"
  
  using namespace std;
  using namespace Mine;
  
  int main(){
      Mine::C1 c1;
      Mine::C2 c2;
      c1.callme();
      c2.callme();
      return 0;
  }
  </code></pre>
  
  <p>When I compile using command "g++ nstest.cpp", I get following error :</p>
  
  <pre><code>/tmp/cc2y4zc6.o: In function `main':
  nstest.cpp:(.text+0x10): undefined reference to `Mine::C1::callme()'
  nstest.cpp:(.text+0x1c): undefined reference to `Mine::C2::callme()'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>If the definitions are moved to the declaration files (nstest1.h and nstest2.h), it works fine. Not sure whats happening here. Am I missing something ?
  Thanks in advance :) .</p>