title: Function to Return Node Pointer
body: <p>everyone! I am making my own linked list template to both practice and for future use; however, I ran into a problem with one of my functions:</p>
  
  <p>Node* LinkedList::FindNode(int x); //is meant to traverse the list and return a pointer to the containing x as its data.</p>
  
  <p>When trying to declare it in my implementation file, I keep getting messages of Node being undefined and incompatibility errors. </p>
  
  <p>Here is my header file: </p>
  
  <pre><code>#pragma once
  using namespace std;
  
  class LinkedList
  {
  private:
      struct Node 
      {   
          int data;
          Node* next = NULL;
          Node* prev = NULL;
      };
  
      //may need to typedef struct Node Node; in some compilers
  
      Node* head;  //points to first node
      Node* tail; //points to last node
      int nodeCount; //counts how many nodes in the list
  
  public:
      LinkedList(); //constructor 
      ~LinkedList(); //destructor
      void AddToFront(int x); //adds node to the beginning of list
      void AddToEnd(int x); //adds node to the end of the list
      void AddSorted(int x); //adds node in a sorted order specified by user
      void RemoveFromFront(); //remove node from front of list; removes head
      void RemoveFromEnd(); //remove node from end of list; removes tail
      void RemoveSorted(int x); //searches for a node with data == x and removes it from list 
      bool IsInList(int x); //returns true if node with (data == x) exists in list
      Node* FindNode(int x); //returns pointer to node with (data == x) if it exists in list
      void PrintNodes(); //traverses through all nodes and prints their data
  };
  </code></pre>
  
  <p>If someone can help me define a function that returns a Node pointer, I would greatly appreciate it!</p>
  
  <p>Thank you!</p>