Is the order of the virtual table important?
<p>I'm new so go easy on me :)
From what my lecturer had told some time ago, the order of the virtual table is important.
But I do not understand the reason for that!!?</p>

<p>Given the next code : </p>

<pre><code>class A
{
public:
    A() {cout &lt;&lt;"1" &lt;&lt; endl;};
    A (const A&amp; s) {cout &lt;&lt; "2" &lt;&lt; endl;}
    ~A () {cout &lt;&lt; "3" &lt;&lt; endl;}
    void f1() {cout &lt;&lt; "4" &lt;&lt; endl; f2();}
    virtual void f2() = 0;
    virtual void f3() {cout &lt;&lt; "5" &lt;&lt; endl;}

};


class B : public A
{
public:
    B() {cout &lt;&lt; "6" &lt;&lt; endl;}
    B(const B&amp; b) : A(b) {cout &lt;&lt; "7" &lt;&lt; endl;}
    ~B() {cout &lt;&lt; "8" &lt;&lt; endl;}

    virtual void f1() {cout&lt;&lt;"9"&lt;&lt;endl;}
    void f2() {cout&lt;&lt;"lO"&lt;&lt;endl; f4();}
    virtual void f2(int i) {cout &lt;&lt; "11" &lt;&lt; endl;}
    virtual void f4() {cout &lt;&lt; "12" &lt;&lt; endl; f3();}

};
</code></pre>

<p>He said that the order is : </p>

<pre><code>A's vtable : 
A::f2()
A::f3()

B's vtable : 
B::f2()
A::f3()
B::f1()
B::f2(int)
B::f4()
</code></pre>

<p>But I don't understand why it is important? He said that the vtable is useless if it's 
not by its correct order, can you please explain why?</p>
