title: Forward declaration just won't do
body: <p>Below are two fragments (ready to compile) of code. In first fragment in which I'm using only forward declaration for a struct while deleting pointer to this struct from a Base class dtor for a Guest class isn't invoked.<br>
  In the second fragment when instead of forward declaration I use full definition of this Guest class using delete in Base works ase intended.<br>
  Why? Why does it make a difference? Isn't forward declaration suppose to be just a note for a compiler saying that the definition of this class/struct is somewhere else?<br>
  I'm very surprised that it just doesn't work intuitively. </p>
  
  <pre><code>//First just forward dclr  
  #include "stdafx.h"
  #include &lt;iostream&gt;
  using std::cout;
  
  struct Guest;
  
  struct Base
  {
      Guest* ptr_;
      Base(Guest* ptr):ptr_(ptr)
      {
          cout &lt;&lt; "Base\n";
      }
      ~Base()
      {
          cout &lt;&lt; "~Base\n";
          delete ptr_;
      }
  };
  
  struct Guest
  {
      Guest()
      {
          cout &lt;&lt; "Guest\n";
          throw std::exception();
      }
      Guest(int)
      {
          cout &lt;&lt; "Guest(int)\n";
      }
      ~Guest()
      {
          cout &lt;&lt; "~Guest\n";
      }
  };
  
  struct MyClass : Base
  {
      Guest g;
      MyClass(Guest* g):Base(g)
      {
          cout &lt;&lt; "MyClass\n";
  
      }
      ~MyClass()
      {
          cout &lt;&lt; "~MyClass\n";
      }
  };
  int _tmain(int argc, _TCHAR* argv[])
  {
      try
      {
          Guest* g = new Guest(1);
      MyClass mc(g);
      }
      catch(const std::exception&amp; e)
      {
          std::cerr &lt;&lt; e.what();
      }
      return 0;
  }
  </code></pre>
  
  <p>//Second - full def</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  using std::cout;
  
  struct Guest
  {
      Guest()
      {
          cout &lt;&lt; "Guest\n";
          throw std::exception();
      }
      Guest(int)
      {
          cout &lt;&lt; "Guest(int)\n";
      }
      ~Guest()
      {
          cout &lt;&lt; "~Guest\n";
      }
  };
  
  struct Base
  {
      Guest* ptr_;
      Base(Guest* ptr):ptr_(ptr)
      {
          cout &lt;&lt; "Base\n";
      }
      ~Base()
      {
          cout &lt;&lt; "~Base\n";
          delete ptr_;
      }
  };
  
  
  
  struct MyClass : Base
  {
      Guest g;
      MyClass(Guest* g):Base(g)
      {
          cout &lt;&lt; "MyClass\n";
  
      }
      ~MyClass()
      {
          cout &lt;&lt; "~MyClass\n";
      }
  };
  int _tmain(int argc, _TCHAR* argv[])
  {
      try
      {
          Guest* g = new Guest(1);
      MyClass mc(g);
      }
      catch(const std::exception&amp; e)
      {
          std::cerr &lt;&lt; e.what();
      }
      return 0;
  }
  </code></pre>