title: What happens when a destructor calls an abstract function
body: <p>I'm having trouble understanding what's the reason for the crash in the following code : </p>
  
  <pre><code>class A {
  public:
      virtual ~A() { goo(); }
      void goo() { absFoo(); }
      virtual void absFoo() = 0;
  
  };
  
  class B : public A {
  public:
      void absFoo() { cout &lt;&lt; "In B \n"; }
  };
  
  int main() 
  {
      B b1;
      b1.goo();
  }
  </code></pre>
  
  <p>The main prints "In B" as expected, but in the end when it crashes, I can't debug it either, the compiler pops a weird message.</p>
  
  <p>So my question is, when the destructor of A calls "goo()", does "absFoo()", crash
  <strong>because we're referring to an abstract function?</strong></p>
  
  <p>Or <strong>does the compiler actually look for a definition in the derived classes?</strong> (And it doesn't exist anymore because it was destructed beforehand so it crashes)</p>
  
  <p>I know that if we had called "absFoo()" directly from the destructor, the reason would have been the abstract function. But since here it's an outside function calling "absFoo()" I'm having trouble understanding the real reason.</p>