title: Linked List: error: expected initializer before '<' token
body: <p>I am getting the error "error: expected initializer before '&lt;' token" when compiling, I need to create a linked list, and I need to turn one of the functions into a template for an assignment, I was wondering how I can fix the error that I am getting.</p>
  
  <pre><code>#ifndef LINK_H
  #define LINK_H
  
  class link {
  public:
      int data;
      link *lnkPtr;
  };
  
  
  class linked
  {
  private:    
  
        link  *head;
  public:
  
          linked(){head = nullptr;}
          ~linked(){};
          void nodeEnd(link *, double num);
          template &lt;class T&gt;
          T nodeBeg&lt;T&gt;(link *, T num);
          void nodeIst(link *, double num);
          void nodeDel(link *, double num);
          link fillLst(int);
          void prntLst(link *);
          void destLst(link *);
          link endLst(link *);
          //void addlink(link *, int);
  };
  
    template &lt;class T&gt;
    T linked&lt;T&gt;::nodeBeg(link* , T num)
  {
       link *newNode; // To point to a new node 
       link *nodePtr; // To move through the list 
  
       // Allocate a new node and store num there. 
       newNode = new link; 
       newNode-&gt;data = num; 
       newNode-&gt;lnkPtr = nullptr; 
  
       // If there are no nodes in the list 
       // make newNode the first node.
        if (!head) 
           head = newNode; 
        else // Otherwise, insert newNode at end. 
        { 
           // Initialize nodePtr to head of list. 
           nodePtr = head; 
  
           // Find the last node in the list. 
           // while (!nodePtr-&gt;linkPtr) 
              nodePtr = nodePtr-&gt;lnkPtr; 
  
  
           nodePtr-&gt;lnkPtr = head; //inserts at beginning
        } 
  }
  #endif /* LINK_H */
  </code></pre>