title: Basic template linked list
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  template &lt;class T&gt;
  class Node{
          friend class LinkedList&lt;T&gt;;
  private:
      T data;
      Node &lt;T&gt; *next;
  public:
      Node();
      Node(T d);
      ~Node();
  };
  
  template &lt;class T&gt;
  Node&lt;T&gt;::Node(){
      T data = 0;
      next = 0;
  }
  
  template &lt;class T&gt;
  Node&lt;T&gt;::Node(T d){
      data = d;
      next = 0;
  
  }
  
  template&lt;class T&gt;
  Node&lt;T&gt;::~Node(){
      delete next;
  }
  
  template &lt;class T&gt;
  class LinkedList{
  private: 
      Node &lt;T&gt; *head;
  public:
      LinkedList();
      ~LinkedList();
      void Push_Front(const T&amp; e);
  }
  
  template&lt;class T&gt;
  LinkedList &lt;T&gt;::LinkedList(){
      head = 0;
  }
  
  template &lt;class T&gt;
  LinkedList&lt;T&gt;::~LinkedList(){
      delete head;
  }
  
  template &lt;class T&gt;
  void LinkedList&lt;T&gt;::Push_Front(const T &amp;e){
      Node&lt;T&gt; *newNode = new Node&lt;T&gt;(e);
  
      if(head == 0)
          head = new Node&lt;T&gt;(e);
  
      newNode-&gt;next = head;
     head = newNode;
  }
  
  
  void main(){
      LinkedList&lt;int&gt; list;
  
      list.Push_Front(10);
  
  
      int t;
      cin&gt;&gt;t;
      return ;
  }
  </code></pre>
  
  <p>I am trying to write a template version of linked list. I ran into some errors and unsure why. The error occurs when I try to make friend class LinkedList, I need to do this so I can access T data from LinkedList.</p>
  
  <pre><code>: error C2059: syntax error : '&lt;'
  : see reference to class template instantiation 'Node&lt;T&gt;' being compiled
  : error C2238: unexpected token(s) preceding ';'
  : error C2143: syntax error : missing ';' before 'template'
  : error C2989: 'LinkedList' : class template has already been declared as a non-class template
  : see declaration of 'LinkedList'
  : 'LinkedList': multiple template parameter lists are not allowed
  : error C2988: unrecognizable template declaration/definition
  : error C2059: syntax error : '&lt;'
  : error C2588: '::~LinkedList' : illegal global destructor
  : fatal error C1903: unable to recover from previous error(s); stopping compilatio
  </code></pre>