title: Doubt with the template instantiation problem in the below snippet of a user defined class
body: <p>Couldn't find anything relevant in forums So ,Please help me with this code .I'm brushing up my c++ concepts and met with a strange error </p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std ;
  class base
  {
      int i ;
  public:
      virtual void f(){cout&lt;&lt;"base" ; return ;};
  };
  class derived: public base
  {
  int j ;
  public:
      void f() {cout&lt;&lt;"derived" ; return ;}
  };
  template&lt;class T&gt;
  class test
  {
  public:
      test(T b) 
      {
          b.f(); cout&lt;&lt;endl&lt;&lt;" "&lt;&lt;sizeof(b)&lt;&lt;endl;
      }
  };
  int main()
  {
  base b ;
  derived d;
  test&lt;derived&gt; t(b); // cannot instantiate user defined type without typename
  }
  </code></pre>
  
  <p>The following code fails to compile with the following error :</p>
  
  <pre><code>test.cpp: In function ‘int main()’:
  test.cpp:28: error: no matching function for call to ‘test&lt;derived&gt;::test(base&amp;)’
  test.cpp:19: note: candidates are: test&lt;T&gt;::test(T) [with T = derived]
  test.cpp:17: note:  test&lt;derived&gt;::test(const test&lt;derived&gt;&amp;)
  </code></pre>
  
  <p>I can make wild guess and arrive at an answer at to why did this happen .If i instantiate  a new base class from the template , everything works just fine , but not this one .
  Can somebody tell me a good source for template instantiations and what are the rules/semantics , what is happening behind the curtain ?
  thanks </p>