title: Get type of the parameter, templates, C++
body: <p>There is the following simplified data  structure:</p>
  
  <p>Object1.h</p>
  
  <pre><code>template &lt;class T&gt;
  class Object1
  {
    private:
       T a1;
       T a2;
    public:
       T getA1() {return a1;}
  };
  </code></pre>
  
  <p>Object2.h</p>
  
  <pre><code>template &lt;class T&gt;
  class Object2: public Object1 &lt;T&gt;
  {
     private:
        T b1;
        T b2;
    public:
       T getB1() {return b1;}
  }
  </code></pre>
  
  <p>Is there any way how to get type T of an object in the folowing function:</p>
  
  <p>Functions.h</p>
  
  <pre><code>template &lt;class Object&gt;
  void (Object *o1, Object *o2)
  {
     T = o1.getA1();  //Is it possible to get T from object o1?
     ...
  }
  </code></pre>
  
  <p>or we must give an additional information about data types of both objects:</p>
  
  <pre><code>template &lt;class T, class Object&gt;
  void (Object *o1, Object *o2)
  {
     T = o1.getA1();
     ...
  }
  </code></pre>