 <p>If you want to use Base still then you are going to have to do this to use those functions:</p> <pre><code>if (Button1) { dynamic_cast&lt;Client*&gt;(connection)-&gt;A(); } else { dynamic_cast&lt;Host*&gt;(connection)-&gt;B(); } </code></pre> <p>And you will need to make connection a pointer. <code>Base * connection</code>.</p> <p>This isn't really ideal though. You should investigate a different way to do it like in the other answers. </p>