Why virtual tables are used to resolve function calls?
<p>In the follwing as i understand the compiler validates the pointer assignment <code>A *p_a = &amp;b;</code> knowing it points to derived class object. but why does it require virtual table to resolve the function call?</p>

<pre><code>class A
{
public:
    A():x(1){}
    virtual void getX() {cout &lt;&lt; x &lt;&lt; endl;}
private:
    int x;
};

class B : public A
{
public:
    B() : A(),x(2){}
    void getX() {cout &lt;&lt; x &lt;&lt; endl;}
private:
    int x;
};

int main()
{
    B b;

    A *p_a = &amp;b;
    p_a-&gt;getX();

}
</code></pre>
