title: Learning to implement a Linked List Queue in C++
body: <p>I would like to implement a linked list using queue in C++. Here is my class:</p>
  
  <pre><code>class LinkedListQueue
  {
  public:
      LinkedListQueue();
      void enQueue(int x);
      void deQueue();
      int peekFront();
      int peekBack();
  
  private:
      struct Node
      {
          int data;
          Node *next;
      };
      Node *head;
      Node *tail;
  };
  
  
  LinkedListQueue::LinkedListQueue()
  {
      tail = 0;
      head = tail;
  }
  void LinkedListQueue::enQueue(int x)
  {
      struct Node* newNode = (struct Node*) malloc(sizeof(struct Node));
      newNode-&gt;data = x;
      newNode-&gt;next = tail;
      tail = newNode;
      if(head != NULL)
      {
        head = tail-&gt;next;
      }
  }
  void LinkedListQueue::deQueue()
  {
      struct Node* newTail = tail-&gt;next;
      delete m_tailPtr;
      tail = newTail;
  }
  int LinkedListQueue::peekFront()
  {
      if(tail != NULL)
    {
      return tail-&gt;data;
    }
    else
    {
      return head-&gt;data;
    }
  }
  int LinkedListQueue::peekBack()
  {
    if(head != NULL)
    {
      return head-&gt;data;
    }
    else
    {
      return tail-&gt;data;
    }
  }
  </code></pre>
  
  <p>I think my functions are working except for the peekFront. I would like to keep the implementation and style the same, just fix the error. Please help.</p>