title: Why is the template specialization function not being accessed
body: <p><strong>Problem Description</strong></p>
  <p>In the following code we have 2 classes <code>A</code> and <code>B</code> where<code>B</code> inherits from <code>A</code>. We also have 2 template functions <code>test(T &amp;t)</code> and <code>test(A &amp;a)</code>.  The output of the code is &quot;A1&quot;.</p>
  <p>Why the <code>test(A &amp;a)</code> function isn't being used in this example?</p>
  <hr />
  <pre><code>// Online C++ compiler to run C++ program online
  #include &lt;iostream&gt;
  class A {};
  class B: public A {};
  
  template&lt;typename T&gt;
  void test(T &amp;t){std::cout &lt;&lt;&quot;A1&quot;;}
  template&lt;&gt;
  void test(A&amp; a){std::cout &lt;&lt;&quot;A2&quot;;}
  
  // If we put test(A&amp; a) before test(T &amp;t) we get the compilation error
  // 'test' is not a template function
  
  int main() {
      A *a = new B();
      test(a);
      delete a;
      return 0;
  }
  </code></pre>