title: Parametric methods with different subtypes
body: <p>today in Theory of Programming Language class we have seen this behaviour in Java:</p>
  
  <pre><code>public class Es {
     ...
     &lt;Y&gt; Y choose(Y y1, Y y2){
           Y returnVal;
           if("some test"){ returnVal = y1;} else{ returnVal = y2;}
           return returnVal;
     }
  }
  </code></pre>
  
  <p>In Main:</p>
  
  <pre><code>Es c = new Es();
  Integer i = 3;
  Float f = (float) 4.5;
  Number n = c.choose(i, f);
  </code></pre>
  
  <p>Where the "incredible" is that the method must choose between Integer and Float for the parametric type Y and opts for the nearest super-type, which is Number.</p>
  
  <p>I would like to reproduce this in C++ but I am stuck...</p>