title: C++, inheritance vs polymorphism
body: <p>I have a little bit "philosophical" question. There is a class A</p>
  
  <pre><code>class A
  {
  
  }
  </code></pre>
  
  <p>and classes A1, A2, A3 derived from A.</p>
  
  <pre><code>class A1 : public A
  {
  }
  
  class A2 : public A
  {
  }
  
  class A3 : public A
  {
  }
  </code></pre>
  
  <p>and one static method processing objects A - A3. Which variant should be preferred?</p>
  
  <pre><code>A)
  class Algorithms  
  {
    //Object of derived class could be use instead of the object base class
    public: void test (const A *a) {}
  };
  </code></pre>
  
  <p>or </p>
  
  <pre><code>B)
  class Algorithms
  {
    public: 
    //Templatize parameter
    template &lt;typename TType&gt;
    void (const TType *a) {}
  };
  </code></pre>
  
  <p>In my opinion, in this case, the option a) is preferable (so the templatization is redundant...)</p>
  
  <p>The option b) means that the input can be any type, that is not in any inheritance relationship to the class A. </p>
  
  <p>It would be used  in the case where the method test() can work with another type B</p>
  
  <pre><code>class B
  {
  }
  </code></pre>
  
  <p>and types A-A3.</p>
  
  <p>Are these conclusions correct or not?</p>