title: C++: error LNK2019: unresolved external symbol referenced in function _main
body: <p>I have some code on C++.</p>
  
  <p>Bird.h</p>
  
  <pre><code>class Bird
  {
      std::string s;
      static int i;
  public:
      Bird();
  
      ~Bird();
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, Bird&amp; b);
  
  };
  </code></pre>
  
  <p>Bird.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt; 
  #include "Bird.h"
  
  
  
  Bird::Bird()
  {
      ++i;
      std::stringstream ss;
      ss&lt;&lt;"Bird#";
      ss&lt;&lt;i;
      s = ss.str();
  }
  Bird::~Bird()
  {
      i--;
  }
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, Bird&amp; b)
  {
      const char* chr = (b.s).c_str();
      return os &lt;&lt; chr &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt; 
  #include "Bird.h"
  
  
  int Bird::i=0;
  
  int main()
  {
      Bird b();
      std::cout &lt;&lt; b;
  }
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Main.obj : error LNK2019: unresolved external symbol "class Bird __cdecl b(void)" (?b@@YA?AVBird@@XZ) referenced in function _main
  </code></pre>
  
  <p>But if I create <code>Bird b;</code> it's OK.
  What can I do?</p>