title: Why does this virtual destructor trigger an unresolved external?
body: <p>Consider the following:</p>
  
  <p>In <strong>X.h:</strong></p>
  
  <pre><code>class X
  {
      X();
      virtual ~X();
  };
  </code></pre>
  
  <p><strong>X.cpp:</strong></p>
  
  <pre><code>#include "X.h"
  
  X::X()
  {}
  </code></pre>
  
  <p>Try to build this (I'm using a .dll target to avoid an error on the missing main, and I'm using Visual Studio 2010):</p>
  
  <blockquote>
    <p>Error  1   error LNK2001: unresolved external symbol "private: virtual __thiscall X::~X(void)" (??1X@@EAE@XZ)</p>
  </blockquote>
  
  <p>Small modifications result in a successful build, however:</p>
  
  <p><strong>X.h:</strong></p>
  
  <pre><code>class X
  {
      inline X(); // Now inlined, and everything builds
      virtual ~X();
  };
  </code></pre>
  
  <p><strong>or</strong></p>
  
  <p><strong>X.h:</strong></p>
  
  <pre><code>class X
  {
      X();
      ~X(); // No longer virtual, and everything builds
  };
  </code></pre>
  
  <p>What causes the unresolved external in the linker when the .dtor is virtual or when the .ctor isn't inlined?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Or, perhaps more interestingly, why do I <em>not</em> get an unresolved external if I make the destructor non-virtual, or if I inline the constructor?</p>