title: Visual Studio Release and Debug builds destructor
body: <p>In Visual Studio 2008 (C++) I have a class destructor (Let's call this class 'A') which deletes a pointer to a different class (Let's call this class 'B').</p>
  
  <p>it looks like this:</p>
  
  <pre><code>A::~A()
  {
      delete B;
      B = NULL;
  }
  </code></pre>
  
  <p>My B class has a pointer to the instance of A that created it. In B's destructor, I delete everything in B, except for the pointer to the instance of A.</p>
  
  <p>In my debug build, it works okay, but fails on my release build..</p>
  
  <p>In the debug build, right after B is deleted but before B is reassigned to NULL, The value of the pointer to the instance of A is something weird like 0xdddddddd.. However in the Release build, it is still pointing to the instance of A.. In both cases the pointer to B is still valid and B is not destroyed.  What is going on and how do I fix it?</p>