Call child virtual function from parent
<p>Please help me out. I am really not good at polymorphism. I have to classes inherited one from the other.</p>

<p>EDIT:
Sorry, fully my mistake. Even I have passed about 2 hours to find the problem. Those who are interested (thanks for all the help)</p>

<pre><code>if (type.compare("TEST1") == 0) result = new Test(ID, database);
if (type.compare("TEST2") == 0) result = new Test(ID, database);
if (type.compare("TOR") == 0) result = new Tor(ID, database);
</code></pre>

<p>"==0" was completely missing.</p>

<pre><code>class A {
public:
    void go() {do();}
    virtual void do() {printf('A');}
}

class B:public A {
    virtual void do() {printf('B');}
}

int main {
    A* obj = new B();
    obj-&gt;go();
}
</code></pre>

<p>The result is 'A' not 'B'. How can I manage to make it 'B'?</p>

<p>Thanks.</p>
