title: base pointer to derived class
body: <p>Suppose there are <code>Base</code> class and <code>Derived</code> class.</p>
  
  <pre><code>Base *A = new Base;
  </code></pre>
  
  <p>Here A is a pointer point to Base class, and <code>new</code> constructs one that A points to.</p>
  
  <p>I also saw </p>
  
  <pre><code>Base *B = new Derived;
  </code></pre>
  
  <p>How to explain this?
  B is a pointer to <code>Base</code> Class, and a <code>Derived</code> class constructed and pointed by B?
  If there is a function derived from <code>Base</code> class, say, <code>Virtual void f()</code>, and it's been overridden in <code>Derived</code> class, then </p>
  
  <pre><code>B-&gt;f()
  </code></pre>
  
  <p>will invoke which version of the function? version in <code>Base</code> class, or version that overridden in <code>Derived</code> Class. </p>
  
  <p>What if there is a new function <code>void g()</code>in <code>Derived</code>, is <code>B-&gt;g()</code> going to invoke this function properly?</p>
  
  <p>One more is, is </p>
  
  <pre><code>int *a = new double;
  </code></pre>
  
  <p>or </p>
  
  <pre><code>double *a = new int;
  </code></pre>
  
  <p>legal?</p>