title: C++ header file linker error
body: <p>I have made the following C++ program which is made up of 3 files:</p>
  
  <p><strong>The thing.h file</strong></p>
  
  <pre><code>    #ifndef THING_H
  #define THING_H
  
  class thing{
    double something;
    public:
           thing(double);
           ~thing();
           double getthing();
           void setthing(double);  
           void print();  
  };
  
  #endif
  </code></pre>
  
  <p><strong>The thing.cpp file</strong></p>
  
  <pre><code>  #include &lt;iostream&gt;
  #include "thing.h"
  
  thing::thing(double d){
  something=d;                    
  }
  
  thing::~thing(){
  std::cout &lt;&lt; "Destructed" &lt;&lt; std::endl;                
  }
  
  double thing::getthing(){
  return something;       
  }
  
  void thing::setthing(double d){
  something = d;     
  }
  
  void thing::print(){
  std::cout &lt;&lt;"The someting is " &lt;&lt; something &lt;&lt; std::endl;     
  }
  </code></pre>
  
  <p><strong>The main file</strong></p>
  
  <pre><code>    #include &lt;iostream&gt;
  #include "thing.h"
  
  int main(){
  
  thing t1(5.5);
  t1.print();
  t1.setthing(7.);
  double d=t1.getthing();
  std::cout &lt;&lt; d &lt;&lt; std::endl;
  
  system("pause");
  return 0;    
  }
  </code></pre>
  
  <p>I had made this program previously all in one file and it ran perfectly but when I try split it into seperate files to create a header I get a linker error, here is the errors I get when I try run it from the main file:</p>
  
  <pre><code>  [Linker error] undefined reference to `thing::thing(double)' 
    [Linker error] undefined reference to `thing::print()' 
    [Linker error] undefined reference to `thing::setthing(double)' 
    [Linker error] undefined reference to `thing::getthing()' 
    [Linker error] undefined reference to `thing::~thing()' 
    [Linker error] undefined reference to `thing::~thing()'
    ld returned 1 exit status  
  </code></pre>
  
  <p>From the above errors it seems asthough the main file doesnt recognise the functions inside the header, how do I fix this please?</p>