How can I make the method of child be called: virtual keyword not working?
<p>The following is my code,</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;string&gt;

using namespace std;

class TestClass
{
  public:
    virtual void test(string st1, string st2);

};

class ExtendedTest: public TestClass
{
  public:
    virtual void test(string st1, string st2);
};

void TestClass::test(string st1, string st2="st2")
{
     cout &lt;&lt; st1 &lt;&lt; endl;
     cout &lt;&lt; st2 &lt;&lt; endl;
}

void ExtendedTest::test(string st1, string st2="st2")
{
     cout &lt;&lt; "Extended: " &lt;&lt; st1 &lt;&lt; endl;
     cout &lt;&lt; "Extended: " &lt;&lt; st2 &lt;&lt; endl;
}

void pass(TestClass t)
{
    t.test("abc","def");
}


int main()
{
   ExtendedTest et;
   pass(et);
   return 0;
}
</code></pre>

<p>When I run the code, the method('test') of base class is called.
But I expect the method of child is called because I specified methods as virtual function.</p>

<p>Then how can I make method of child class be called ? Thank you.</p>
