Simple SingleLinkedList Implementation in C++ Below I have a very simple LinkedList implementation. I was wondering if there are any memory leak problems with this and if I used the pointers correctly. I just started practicing with C++ and hoping to improve my use of pointers and memory leak management.

#include &lt;iostream&gt;

struct node{
    int data;
    node *next;

    node::node(){}

    node::node(const int &amp; val, node* link)
            : data(val), next(link)
    {}
};

class LinkedList
{

    public:
        LinkedList();
        void addToEnd(int val);
        void printList();
        void deleteList(node *head);
        void deleteNode(node *toBeDeleted);
        node* get(int index);

    private:
        int size;
        node *head, *tail;

};

LinkedList::LinkedList(){
    head = NULL;
    tail = NULL;
}

node* LinkedList::get(int index){

    node* temp = head;
    int pointer = 0;

    while(pointer != index){
        temp = temp-&gt;next;
        pointer++;
    }

    return temp;

}

void LinkedList::addToEnd(int val){

    node *temp = new node(val, NULL);
    // temp-&gt;data = val;
    // temp-&gt;next = NULL;

    if(head==NULL){
        head = temp;
        tail = temp;
        temp = NULL;
    }
    else{
        tail-&gt;next = temp;
        tail = temp;
    }
}

void LinkedList::printList(){

    node *temp = head;
    //temp = head;
    while(temp){
        cout&lt;&lt;temp-&gt;data&lt;&lt;"\t";
        temp = temp-&gt;next;
    }
}

//Supposed to delete the nodes coming after the input node
void LinkedList::deleteList(node *start){
    if(start){
        deleteList(start-&gt;next);
        delete start;
    }
}

//deletes a single node
void LinkedList::deleteNode(node* toBeDeleted){

    node* temp = head;

    if(head == toBeDeleted){
        head = head-&gt;next;
        delete temp;
    }

    while(temp-&gt;next != toBeDeleted){
        temp = temp-&gt;next;
    }

    if(temp-&gt;next){
        temp-&gt;next = toBeDeleted-&gt;next;
        delete toBeDeleted;
    }

}

int main(){


    LinkedList list;

    for(int i=0;i&lt;4;i++){
        list.addToEnd(i+1);
    }

    list.deleteList(list.get(2));
    //list.deleteNode(list.get(2));

    list.printList();

    return 0;
}


Currently, the main function doesn't run after deleteList. I am not necessarily asking about how to fix that part, I just wanted to learn tips about better pointer uses and memory leak possibilities.

Edit:

I have commented the use of deleteList and deleteNode and below I have added a destructor showing how I was planning to use deleteList. 

LinkedList::~LinkedList(){
    deleteList(head);
}
You asked about pointer usage, so a topic which may interest you is:

Indirect Pointers

Indirect pointers fall into the "easy to use, difficult to think up" category, but are useful in many cases, so are worth understanding, and apply to a linked list.

In your implementation of deleting a node there are two cases, one where the head should be deleted, and one where somewhere else should be, and in both cases you do roughly the same thing. We can get rid of that duplicated code.

Instead of

node* temp = head;


we can take the pointer to head, like

node** indirect = &amp;head;


and as we go along, we can move indirect to the pointer to this node's next pointer

indirect = &amp;((*indirect)-&gt;next);


Put together, this results in a method which looks something like this:

void SingleLinkedList::deleteNode(node* toBeDeleted){ 
    node* prev = nullptr;
    node** indirect = &amp;head;

    while(*indirect != toBeDeleted){
        prev = *indirect;
        indirect = &amp;((*indirect)-&gt;next);
    }

    *indirect = toBeDeleted-&gt;next;
    delete toBeDeleted;

    if(!(*indirect)) tail = prev;
}


Notice that the special case can be totally removed because, in the first assignment to indirect, indirect contains a pointer to somewhere in the stack (where head is), and in future assignments it has a value in the heap (where the current node is)