title: Can std::function and inheritance coexist?
body: <p>I have one file with abstract class</p>
  
  <pre><code>struct Abstract {
      virtual bool preflightCheck(void) = 0;
      std::function&lt;void(Abstract *)&gt; didIssueError;
      virtual ~Abstract() {}
  }
  </code></pre>
  
  <p>One file with derived class</p>
  
  <pre><code>class Derived : public Abstract {
      bool preflightCheck(void) {
          if(didIssueError != nullptr)
              this-&gt;didIssueError(reinterpret_cast&lt;MediaAssetAbstract*&gt;(this));
      }
  }
  </code></pre>
  
  <p>And then I have file where I call <code>didIssueError</code> as lambda</p>
  
  <pre><code>bool testDerived(Abstract &amp; derived) {
      derived.preflightCheck();
      derived.didIssueError = [&amp;derived](Abstract * derived) {
          std::cout &lt;&lt; "error" &lt;&lt; std::endl;
      };
      return true;
  }
  
  int main() {
      auto derived = Derived();
      assert(testDerived(derived));
      return 0;
  }    
  </code></pre>
  
  <p>If I remove the check on <code>nullptr</code>, the program will crash with message 
   <code>terminate called after throwing an instance of 'std::bad_function_call' what():  bad_function_call</code>.</p>
  
  <p>Where could be problem, please? With the inaccesibility from derived class to the <code>didIssueError</code>?</p>