title: Getting template error. 'T" was not declared in this scope
body: <p>I am just practicing a bst program using templates. Below is the program.</p>
  
  <pre><code>template&lt;class T&gt;
  class bstnode
  {
      public: 
          T key;
          bstnode *left, *right;
          bstnode()
          {
              left=right=0;
          }
          bstnode(const T&amp; el, bstnode *l=0, bstnode *r=0)
          {
              key=el;
              left=l;
              right=r;
          }
  };
  
  template&lt;class T&gt;
  class bst
  {
      protected:
          bstnode&lt;T&gt;* root;
      public:
          bst()
          {
              root=0;
          }
          void insert(T);
          void display();
          void inorder(bstnode&lt;T&gt; *);
  };
  
  void inorder(bstnode &lt;T&gt;* b1)  //ERROR 'T' was not declared in scope
  {
      if(b1)
      {
          cout&lt;&lt;b1-&gt;key;
      }
      else
      {
          return;
      }
      inorder(b1-&gt;right);        
      inorder(b1-&gt;left);
  }
  
  template&lt;class T&gt;
  void bst&lt;T&gt;::display()
  {
      //bstnode&lt;T&gt; * b=new bstnode&lt;T&gt;();
      //b=root;
      inorder(root);  
  }
  
  template&lt;class T&gt;
  void bst&lt;T&gt;::insert(T v)
  {
      bstnode&lt;T&gt;* b=new bstnode&lt;T&gt;();
      b-&gt;key=v;
      if(root==NULL)
      {
          root=b;
      }
      else
      {
          bstnode&lt;T&gt;* temp=root;
          while((temp-&gt;left!=NULL)||(temp-&gt;right!=NULL))
          {
              if(temp-&gt;key &gt; b-&gt;key)
              {
                  temp=temp-&gt;right;
              }
              else
              {
                  temp=temp-&gt;left;
              }
          }
          if(temp-&gt;key &lt; b-&gt;key)
          {
              temp-&gt;left=b;
          }
          else
          {
              temp-&gt;right=b;
          }   
      }
  }
  
  int main(int argc, char *argv[])
  {
      bst&lt;int&gt;b;
      b.insert(10);
      b.insert(5);
      b.insert(2);
      return 0;
  }
  </code></pre>
  
  <p>During compiling I am getting error 'T' was not declared in scope for the inorder function.</p>
  
  <p>Please help me in solving this problem.</p>