title: C++ equivalent of using <T extends Class> for a java parameter/return type
body: <p>In java, to make a function that returns an object that is the same type as a parameter and extends a certain class, I would type:</p>
  
  <pre class="lang-java prettyprint-override"><code>public &lt;T extends MyClass&gt; T foo(T bar) {...}
  </code></pre>
  
  <p>Is there a C++ equivalent of this?</p>
  
  <p>In other words, how do I make a function that takes any class that extends a certain class, and returns that same type? (This is for the purpose of abstract/pure virtual classes).</p>