how to write a function that return a type which is return type of its sub-funtions
<p>I want to write a function that calls serval sub functions and return the result of these sub functions.</p>

<pre><code>sub functions:
template&lt;class A&gt; A sub1(A a)
template&lt;class B&gt; B sub2(B b, int i)
template&lt;class C&gt; C sub3(C c, string p)
</code></pre>

<p>THE function will call these accordingly in the switch statement.
Sorry I only have psudo code since I am confused with the issue and not start to write the code.</p>

<pre><code>mf(string s)
{
  int k;
  k = process(s)
  string
  switch (k){
  case 0:
    return sub1(k);
  case 1:
    return sub2(s, k);
  case 2:
    return sub3(k, s);
  default:
    break;
  }
}
</code></pre>

<p>How can I define mf above since there is no return type for it now? using template again?
By the way, my c++ compiler does support c++ 11 standard which I am not so familiar with.</p>

<p>Thanks in advance.</p>
