title: Unresolved external when method defined in cpp file, but not when in header
body: <p><strong>Update 2</strong>: Found the forward declare bug that caused this</p>
  
  <p><strong>Update</strong>: <em>Compiled using Visual Studio 2010 stock compiler, with c++0x enabled.</em></p>
  
  <p>I have a class with a member function which is behaving strangely. </p>
  
  <p>When I define the method in the cpp file the linker falls over with an "unresolved external symbol" error. When I move the definition to the header it compiles fine. </p>
  
  <p>1) This is not a templated method
  2) The cpp file is definitely being compiled 
  3) I'm stumped</p>
  
  <p>Any thoughts?</p>
  
  <p>header file</p>
  
  <pre><code>// THIS IS THE ERROR HERE: I forward declare TPA as a class, when it is actually a struct
  class TollingPathAttributes; // forward declare the TollingPathAttributes struct as a class (doh!)
  
  class TollingPathAttributesOutput
  {
  public:
      TollingPathAttributesOutput(HighwayCommand* command);
      ~TollingPathAttributesOutput();
  
      void foo();
      void AddPathAttributes(boost::shared_ptr&lt;TollingPathAttributes&gt; attributes);
  
  protected:
      string                                      m_outputFilename;
      vector&lt;shared_ptr&lt;TollingPathAttributes&gt;&gt;   m_data;
      queuing_mutex                               m_dataMutex;
  };
  </code></pre>
  
  <p>cpp file</p>
  
  <pre><code>void TollingPathAttributesOutput::foo() {}
  
  void TollingPathAttributesOutput::AddPathAttributes(boost::shared_ptr&lt;TollingPathAttributes&gt; attributes)
  {
      queuing_mutex::scoped_lock lock(m_dataMutex);
      m_data.push_back(attributes);
  }
  </code></pre>
  
  <p>invoking call</p>
  
  <pre><code>m_output-&gt;foo();  // compiles and links no problem
  boost::shared_ptr&lt;TollingPathAttributes&gt; attr = 
      boost::make_shared&lt;TollingPathAttributes&gt;(origin, dest, UNTOLLED_OPTION, vector&lt;int&gt;(), 0.0, 0.0);
  m_output-&gt;AddPathAttributes(attr); // compiles fine, but only links correctly if I move the definition to the header
  </code></pre>
  
  <p>link error</p>
  
  <pre><code>1&gt;OtCustomZenith_logic.lib(TollingPathAttributesRecorder.obj) : error LNK2019: unresolved external symbol "public: void __thiscall TollingPathAttributesOutput::AddPathAttributes(class boost::shared_ptr&lt;class TollingPathAttributes&gt;)" (?AddPathAttributes@TollingPathAttributesOutput@@QAEXV?$shared_ptr@VTollingPathAttributes@@@boost@@@Z) referenced in function "public: virtual void __thiscall TollingPathAttributesRecorder::Record(class TolledPath &amp;,class boost::shared_ptr&lt;class Path&gt;,int)" (?Record@TollingPathAttributesRecorder@@UAEXAAVTolledPath@@V?$shared_ptr@VPath@@@boost@@H@Z)     
  1&gt;..\..\..\OT\OtCustomZenith_test.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>