title: Unresolved External Symbol, Header File Cause
body: <p>I've searched (and found) topics to this error, but wasn't able to apply them to my specific situation, yet. So here it goes:</p>
  <p><strong>Rational.h</strong></p>
  <pre><code>#include &lt;iostream&gt;
  class Rational{
  public:
      Rational(int a = 0, int b = 1);
      Rational(const Rational &amp;number);
      ~Rational();
  
      static Rational add(const Rational &amp;a, const Rational &amp;b);
      static Rational sub(const Rational &amp;a, const Rational &amp;b);
      static Rational mult(const Rational &amp;a, const Rational &amp;b);
      static Rational div(const Rational &amp;a, const Rational &amp;b);
  
      void reduce(Rational a);
  
      int get_nom() const;
      int get_denom() const;
      void set_nom(int a);
      void set_denom(int b);
  
      void printOut();
  
  private:
      int nom;
      int denom;
  
      int greatCommonDiv(int a, int b);
  };
  </code></pre>
  <p><strong>Rational.cpp</strong></p>
  <pre><code>#include &lt;iostream&gt;
  
  class Rational{
  public:
      Rational(int a = 0, int b = 1):
          nom(a), denom(b){
      }
      Rational(const Rational &amp;number):
          nom(number.get_nom()), denom(number.get_denom()){
      }
      ~Rational(){
      }
  
      static Rational add(const Rational &amp;a, const Rational &amp;b){
          Rational sum( ((a.get_nom() * b.get_denom()) + (a.get_denom() * b.get_denom())), (a.get_denom() * b.get_denom()) );
          sum.reduce();
          return sum;
      }
      static Rational sub(const Rational &amp;a, const Rational &amp;b){
          Rational diff( ((a.get_nom() * b.get_denom()) - (a.get_denom() * b.get_denom())), (a.get_denom() * b.get_denom()) );
          diff.reduce();
          return diff;
      }
      static Rational mult(const Rational &amp;a, const Rational &amp;b){
          Rational product(a.get_nom() * b.get_nom(), a.get_denom() * b.get_denom());
          product.reduce();
          return product;
      }
      static Rational div(const Rational &amp;a, const Rational &amp;b){
          Rational quotient(a.get_nom() * b.get_denom(), a.get_denom() * b.get_nom());
          quotient.reduce();
          return quotient;
      }
      void reduce(){
          int ggT = greatCommonDiv(nom, denom);
          nom = nom / ggT;
          denom = denom / ggT;
      }
  
      int get_nom() const { return nom; }
      int get_denom() const { return denom; }
      void set_nom(int a){ nom = a; }
      void set_denom(int b){ denom = b; }
  
      void printOut(){
          std::cout &lt;&lt; nom &lt;&lt; &quot;/&quot; &lt;&lt; denom &lt;&lt; std::endl;
          return;
      }
  
  private:
      int nom;
      int denom;
  
      int greatCommonDiv(int a, int b){           
          if(b == 0)
              return a;
          else return greatCommonDiv(b, a % b);
      }
  };
  </code></pre>
  <p><strong>Source.cpp</strong></p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;Rational.h&gt;
  
  int main(){
  Rational a(5,3);
  a.printOut();
  }
  </code></pre>
  <p>MSVS gives me 3 errors:</p>
  <blockquote>
  <p>1&gt;Source.obj : error LNK2019: unresolved external symbol &quot;public: __thiscall Rational::Rational(int,int)&quot; (??0Rational@@QAE@HH@Z) referenced in function _main</p>
  <p>1&gt;Source.obj : error LNK2019: unresolved external symbol &quot;public: __thiscall Rational::~Rational(void)&quot; (??1Rational@@QAE@XZ) referenced in function _main</p>
  <p>1&gt;Source.obj : error LNK2019: unresolved external symbol &quot;public: static void __cdecl Rational::printOut(void)&quot; (?printOut@Rational@@SAXXZ) referenced in function _main</p>
  </blockquote>
  <p>I can't figure out, why this happens as I'm pretty certain that he can find the .h and .cpp files at the right places.</p>