How to define a different type variable in C++?
<p>I have the following piece of code for example.</p>

<pre><code>template &lt;class T&gt;
void g(T b){
  ;
}

template &lt;class T&gt;
void h(T b){
   ;
}

class T{
   method X;
   method Y;
   method Z; //many methods but the implementation of the methods are different from TT
};

class TT{
   method X;
   method Y;
   method Z; //the implementation of the methods are different from T
}
void f(){

  if(a==1){
  T b;  //use type T to define b
  } else{
  TT b; //use type TT to define b
  }

 g(b);
 h(b);
 i(b);// I need to use b for many different functions.
</code></pre>

<p>}</p>

<p>I also need the scope of variable b is in the function f.</p>

<p>In class T and TT, there are many methods but the implementation of the methods are different.</p>

<p>Any suggestions?</p>
