title: Why virtual function can't be unimplemented when allocated with 'new'?
body: <pre><code>struct A
  {
    virtual void foo();  // unused and unimplemented
    virtual void bar () {}
  };
  
  int main ()
  {
    A obj;        // ok
    obj.bar();  // &lt;-- added this edition
    A* pm = (A*)malloc(sizeof(A)); // ok
    A* pn = new A; // linker error
  }
  </code></pre>
  
  <p>For objects on stack <a href="http://www.ideone.com/aYf5W" rel="nofollow">it works fine</a>. But for allocation on heap with <code>new</code> (not <code>malloc</code>), it gives linker error:</p>
  
  <pre><code>undefined reference to `vtable for A'
  </code></pre>