<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Template metaprogramming - Page 14 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Template_metaprogramming&amp;p=13">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Template_metaprogramming&amp;p=15">3.Next</a>
</p>
<p>of their base object but where the derived objects' methods will be invoked, as in this code<syntaxhighlight lang="cpp">class Base {public:    virtual void method() {         std::println("Base");     }</syntaxhighlight></p>

<p>    virtual ~Base() {}};</p>

<p>class Derived : public Base {public:    virtual void method() {         std::println("Derived");    }};</p>

<p>int main() {    Base* b = new Derived;    b->method(); // outputs "Derived"    delete b;    return 0;}where all invocations of <code>virtual</code> methods will be those of the</p><p>
<a accesskey="1" href="page.php?w=Template_metaprogramming&amp;p=13">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Template_metaprogramming&amp;p=15">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
