title: How do I return a pointer to an Object's Struct with a method?
body: <p>I'm trying to write a method in C++ for a custom list class, called List. It's a linked list made up of Nodes, which are the various items. For the method, I want it to return a pointer to a Node, but get an error saying that " 'Node' does not name a type."
  Note that the sort() method is still in progress, and I'm waiting on setMyNext() for that.</p>
  
  <pre><code>template&lt;class Item&gt;
  class List {
  public:
  List();
  List(const List&amp; original);
  virtual ~List();
  void sort();
  
  List&amp; operator=(const List&amp; original);
  bool operator==(const List&amp; original)const;
  bool operator!=(const List&amp; l2) const;
  
  private:
  void print()const;
  unsigned mySize;
  struct Node{
      Node();
      Node(Item item, Node * next);
      ~Node();
      void print()const;
      Node * setMyNext(Node * newNext);
      Item myItem;
      Node * myNext;
  };
  
  Node * myFirst;
  Node * myLast;
  
  friend class ListTester;
  };
  
  
  
  template&lt;class Item&gt;
  List&lt;Item&gt;::List() {
  myFirst=NULL;
  myLast=NULL;
  mySize=0;
  }
  
   template&lt;class Item&gt;
  List&lt;Item&gt;::List(const List&amp; original){
  myFirst=myLast=NULL;
  mySize=0;
  if(original.getSize()&gt;0){
      Node * oPtr = original.myFirst;
      while(oPtr!=NULL){
          append(oPtr-&gt;myItem);
          oPtr=oPtr-&gt;myNext;
      }
  }
  }
  
  template&lt;class Item&gt;
  List&lt;Item&gt;::Node::Node(){
  myItem=0;
  myNext=NULL;
  }
  
  
  template&lt;class Item&gt;
  List&lt;Item&gt;::Node::Node(Item item, Node * next){
  myItem=item;
  myNext= next;
  }
  
  template&lt;class Item&gt;
  List&lt;Item&gt;::~List() {
  //  cout&lt;&lt;"Deleting List..."&lt;&lt;endl;
  delete myFirst;
  myFirst=myLast=NULL;
  mySize=0;
  }
  
  template&lt;class Item&gt;
  void List&lt;Item&gt;::sort(){
  //get my first 2 items
  if(mySize&lt;2)
      return;
  Node * compareEarly=myFirst;
  Node * compareLate=myFirst-&gt;myNext;
  //compare
  if(compareEarly-&gt;myItem &gt; compareLate-&gt;myItem){
  //If 2&lt;1, set 0's next pointer to 2, set 2's next to 1, set 1's next to 3
      cout&lt;&lt;"big"&lt;&lt;endl;
  
  }
      //This needs a set previous pointer and set next item's pointer
  
      //increment
  }
  
  template&lt;class Item&gt;
  Node * List&lt;Item&gt;::Node::setMyNext(Node * newNext){
  myNext=newNext;
  }
  </code></pre>