return type unknown for template classes
<p>I have created a matrix class and want to add two matrices of different data types. Like for int and double return type of matrice should be double. How can I do that???
This is my code</p>

<pre><code>template&lt;class X&gt;
class Matrix
{
..........
........
template&lt;class U&gt;
Matrix&lt;something&gt; operator+(Matrix&lt;U&gt; &amp;B)
{
if((typeid(a).before(typeid(B.a))))
Matrix&lt;typeof(B.a)&gt; res(1,1);
else
Matrix&lt;typeof(a)&gt; res(1,1);
}
</code></pre>

<p>What should be "something" here??? </p>

<p>Also what should be done so that I can use "res" outside if else statement??? </p>
