title: How to call virtual function of derived class through base class pointer
body: <p>Let's see this code:</p>
  
  <pre><code>class CBase
  {
   public:
      virtual vfunc() { cout &lt;&lt; "CBase::vfunc()" &lt;&lt; endl; }
  };
  
  class CChild: public CBase
  {
   public:
      vfunc() { cout &lt;&lt; "CChild::vfunc()" &lt;&lt; endl; }
  };
  
  int main() 
  {
   CBase *pBase = new CBase;
   ((CChild*)pBase)-&gt;vfunc(); // !!! important 
   delete pBase;
   return 0;
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>CBase::vfunc()
  </code></pre>
  
  <p>But I want to see:  CChild::vfunc()</p>
  
  <p>Explicit ((CChild*)pBase) casts to type "CChild*". So why to call derived vfunc() I need replace "important" string with:
      ((CChild*)pBase)->CChild::vfunc();</p>