title: Why I am getting error, template argument required for ‘struct node’?
body: <p>I have written the following code to implement Linked List in C++. But I am getting the Errors on compiling it. I think the problem is with the use of Template. </p>
  
  <pre><code>#include&lt;iostream&gt;
  template&lt;class T&gt;
  struct node{
      T data;
      struct node *next;
  };
  
  template&lt;class T&gt;
  void push(struct node **headRef ,T data){
      struct node *temp =(struct node*) malloc(sizeof(struct node));
      temp-&gt;data=data;
      temp-&gt;next=*headRef;
      *headRef=temp;
  }
  int main(){
      struct node *ll = NULL;
      push(&amp;ll,10);
      push(&amp;ll,3);
      push(&amp;ll,6);
      push(&amp;ll,8);
      push(&amp;ll,13);
      push(&amp;ll,12);
  }
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>MsLL.cpp:9:18: error: template argument required for ‘struct node’
  MsLL.cpp: In function ‘void push(int**, T)’:
  MsLL.cpp:10:8: error: template argument required for ‘struct node’
  MsLL.cpp:10:19: error: invalid type in declaration before ‘=’ token
  MsLL.cpp:10:28: error: template argument required for ‘struct node’
  MsLL.cpp:10:28: error: template argument required for ‘struct node’
  MsLL.cpp:10:21: error: expected primary-expression before ‘struct’
  MsLL.cpp:10:21: error: expected ‘)’ before ‘struct’
  MsLL.cpp:11:7: error: request for member ‘data’ in ‘temp-&gt;’, which is of non-class type ‘int’
  MsLL.cpp:12:7: error: request for member ‘next’ in ‘temp-&gt;’, which is of non-class type ‘int’
  MsLL.cpp: In function ‘int main()’:
  MsLL.cpp:16:8: error: template argument required for ‘struct node’
  MsLL.cpp:16:17: error: invalid type in declaration before ‘=’ token
  </code></pre>