title: Pure virtual method called
body: <p>I understand why calling a virtual function from a constructor is bad, but I'm not sure why defining a destructor would result in a "pure virtual method called" exception.  The code uses const values to reduce the use of dynamic allocation - possibly also the culprit.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class ActionBase {
   public:
      ~ActionBase() { } // Comment out and works as expected
  
      virtual void invoke() const = 0;
  };
  
  template &lt;class T&gt;
  class Action : public ActionBase {
   public:
      Action( T&amp; target, void (T::*action)())
       : _target( target ), _action( action ) { }
  
      virtual void invoke() const {
          if (_action) (_target.*_action)();
      }
  
      T&amp;   _target;
      void (T::*_action)();
  };
  
  class View {
   public:
      void foo() { cout &lt;&lt; "here" &lt;&lt; endl; }
  };
  
  class Button : public View {
   public:
      Button( const ActionBase&amp; action )
       : _action( action ) { }
  
      virtual void mouseDown() {
          _action.invoke();
      }
  
   private:
      const ActionBase&amp; _action;
  };
  
  int main( int argc, char* argv[] )
  {
      View view;
      Button button = Button( Action&lt;View&gt;( view, &amp;View::foo ) );
      button.mouseDown();
  
      return 0;
  }
  </code></pre>