 <p>This does not make much sense to begin with. A <code>Derived</code> should be able to be used anywhere a <code>Base</code> is expected, so you should be able to do</p> <pre><code>Base *foo = new Base(); Apple x = foo-&gt;func(); // this is fine Base *bar = new Derived(); Apple y = foo-&gt;func(); // oops... </code></pre> <p>I think you need to look into a different design. It's not clear just what your goal is here, but I'm guessing you might either want <code>Base</code> to be a class template with <code>Fruit</code> as a template parameter, or maybe you need to get rid of the inheritance altogether.</p>