title: void* convert to base class and invoke virtual function
body: <p>I have some codes like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  //base class
  class Base
  {
      public:
          Base(){}
  
          virtual void f()
          {
              cout&lt;&lt;"father.f()"&lt;&lt;endl;
          }
          virtual ~Base(){}
  };
  //a empty class
  class Base1
  {
      public:
          Base1(){}
          virtual ~Base1()
          {
              cout&lt;&lt;"~base1"&lt;&lt;endl;
          }
  };
  //the child class of the base class
  class Child :public Base
  {
      public:
          Child(){}
          virtual ~Child(){}
  };
  //the grandchild class of the base class,and child class of the base1 class
  class Grand :public Base1,public Child
  {
      public:
          Grand(){}
          virtual ~Grand(){}
          //overwrite base's f()
          void f()
          {
              cout&lt;&lt;"grand.f"&lt;&lt;endl;
          }
  };
  int main()
  {
      void *v = new Grand();
      Base *b = (Base*)(v);
      //i think it print "father.f()",but it print"~base1"
      b-&gt;f();
      return 0;
  }
  </code></pre>
  
  <p>I run these code in code::blocks(version13.12),but it print "~base1",I don't konw why it don't print "father.f()"。I think the v point to the address of the grand's virtual table,so when i convert v to base and invoke the f function,then b invoke the first virtual function in the virtual table.</p>
  
  <p>I do not know i'm right or wrong,can u tell me.Thank all of!</p>