title: I have member that is a pointer to a parameterized function, can I extend a parameter type?
body: <p>Constructor takes and sets a member that has the type:</p>
  
  <pre><code>void (*callBackFunc)(void *context, VideoSprite *pCaller)
  </code></pre>
  
  <p>Now I need to extend this to include more data than <code>VideoSprite</code> holds. I will <code>static_cast</code> in the <code>static</code> callback like this:</p>
  
  <pre><code>static void staticFuncToInitRot(void *context, VideoSprite *pCaller)
  {
      spinningSprite *winSpin = static_cast&lt;spinningSprite*&gt;(pCaller);
  </code></pre>
  
  <p>Is this okay? No risk of slicing or anything hard to detect? Also can you tell me which c'tor will be called and why?</p>
  
  <pre><code>    DelayedCallback(void *context, VideoSprite *pCaller, std::function&lt;void(void *context, VideoSprite *pCaller)&gt; lambda) :
          lambda(lambda),
          callBackFunc(NULL),
          context(context),
          pCaller(pCaller),
      {}
      DelayedCallback(void *context, VideoSprite *pCaller, void (*callBackFunc)(void *context, VideoSprite *pCaller)) :
          callBackFunc(callBackFunc),
          context(context),
          pCaller(pCaller),
      {}
  </code></pre>
  
  <p>Only one alternative member is <code>NULL</code>ified because the callback executes with:</p>
  
  <pre><code>            if (callBackFunc) callBackFunc(context, pCaller);
              else lambda(context, pCaller);
  </code></pre>
  
  <p>I can't remember if I needed the <code>lambda</code> or left it there for perceived future proofing benefits.</p>
  
  <p>The c'tor is called like this from <code>VideoSprite</code> (<code>context</code> is <code>nullptr</code>)</p>
  
  <pre><code>actionList.push_back(new DelayedCallback(context, this, callBackFunc));
  </code></pre>
  
  <p>where <code>callBackFunc</code> is a pointer to </p>
  
  <pre><code>static void staticFuncToInitRot(void *context, VideoSprite *pCaller)
  </code></pre>
  
  <p>I really don't need a <code>dynamic_cast</code> thanks and I appreciate your concern.</p>