title: C++ can't use class from another file
body: <p>I'm C++ by writing small programs. I'm too the point of working with multiple files. I'm stuck on using a class from another file. I made a simple test project to demonstrate my problem. I have 3 files.</p>
  
  <p>testheader.h</p>
  
  <pre><code>#ifndef __testheader_H_INCLUDED__   // if Node.h hasn't been included yet...
  #define __testheader_H_INCLUDED__   //   #define this so the compiler knows it has been included
  
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  class testheader { 
      public:
      testheader(std::string name){}
      void write(){}
  };
  #endif
  </code></pre>
  
  <p>testheader.cpp</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  class testheader {
      public:
      testheader(string name){
          cout &lt;&lt; name &lt;&lt; endl;
      }
      void write(){
          cout &lt;&lt; "stuff" &lt;&lt; endl;
      }
  };
  </code></pre>
  
  <p>anotherfile.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "testheader.h"
  
  using namespace std;
  
  int main () {
      cout &lt;&lt; "testing" &lt;&lt; endl;
      testheader test("mine");
      test.write();
      return 0;
  }
  </code></pre>
  
  <p>I compile them all in Linux using g++ with the command</p>
  
  <pre><code>g++ -std=c++11 testheader.cpp anotherfile.cpp testheader.h -o another
  </code></pre>
  
  <p>When I run the "another" executable the output is</p>
  
  <p>testing</p>
  
  <p>what I'm expecting is the out put</p>
  
  <p>testing
  mine
  stuff</p>
  
  <p>It seems my class object "test" is compiling as null. I'm not sure if it's my header or the files aren't linked properly. When the testheader object is created in main it's clearly not calling the constructor in the testheader.cpp as expected. Can you help a noob out?</p>
  
  <p>Thanks,
  Noob</p>