title: Creating a generic linked list in c++ without stl
body: <p>Can someone help creating <code>generic linkedlist</code> without <code>STL</code>. How do I declare head in main. Is it struct node&lt;>* head ? or struct node* head ? I got a an error using both and it was something like a template declaration cannot appear at block scope</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  template&lt;class T&gt;
  struct node
  {
      T data;
      struct node&lt;T&gt;* next;
  };
  
  template&lt;class T&gt;
  void Push(struct node&lt;T&gt;** H,T dat)
  {
      struct node&lt;T&gt; * newnode=(struct node&lt;T&gt; * )malloc(sizeof(struct node&lt;T&gt;)) ;
      newnode-&gt;data=dat;
      newnode-&gt;next=*H;
      *H=newnode;
  
  }
  
  
  int main() {
  
      struct node&lt;&gt;* head=NULL;
      struct node&lt;&gt;* current;
      int a=10;
      float f=10.1;
  
  
      Push&lt;int&gt;(&amp;head,a);
      Push&lt;float&gt;(&amp;head,f);
  
  
      current=head;
      while(current)
      {
          cout&lt;&lt;current-&gt;data;
          current=current-&gt;next;
      }
  
      //code
      return 0;
  }
  </code></pre>