Linked list not working in c++ : <p>So i'm trying to get the linked list and this is my code so far. Everything look fine when i'm adding a node at the front of my list, but when i try to add my first node at the back, my code compile but return me -1. I'm not sure what's wrong with it but I know it's in the insertBack() function. And by the way, if there's anything else wrong let me know, it's my first try on linked list!
Thanks!</p>

<pre><code>#include "LinkedList.h"
#include &lt;iostream&gt;
#include &lt;stddef.h&gt;

LinkedList::LinkedList()
{
    head=NULL;
    length=0;
}

void LinkedList::InsertFront(int item)
{
    Node *temp = new Node;
    temp-&gt;data = item;
    temp-&gt;next = head;
    head = temp;
    length++;
}

void LinkedList::InsertBack(int item)
{
    Node *temp1 = new Node;
    temp1 = head;

    while(temp1-&gt;next != NULL)
    {
        temp1 = temp1-&gt;next;
    }
    Node *temp = new Node;
    temp-&gt;data = item;
    temp-&gt;next = NULL;
    temp1-&gt;next = temp;

    length++;
}

void LinkedList::MakeEmpty()
{
    Node *temp;
    while(head!= NULL)
    {
        temp = head;
        head = head-&gt;next;
        delete temp;
    }
    length;
}

void LinkedList::ShowItems()
{
    Node *temp = head;
    while(temp != NULL)
    {
        std::cout&lt;&lt;temp-&gt;data&lt;&lt;std::endl;
        temp = temp-&gt;next;
    }
}


LinkedList::~LinkedList()
{
    MakeEmpty();
}
</code></pre>
