Deleting Node from Circular Doubly Linked List
<p>I've written code to insert elements into a circular doubly linked list and to display these elements. I'm supposed to also be able to delete the tail node from the the list, as well as search the list for a specific element. </p>

<p>This is my working code for add and print:</p>

<pre><code>void Circular_DLList::add_to_tail(int a)
{
    DLLNode *temp = new DLLNode;
    temp-&gt;info = a;
    if (is_empty()) {   
        tail = temp;
        temp-&gt;next = tail;
        temp-&gt;prev = tail;
    }
    else {
        temp-&gt;next = tail-&gt;next;
        temp-&gt;prev = tail;
        tail = temp;
        tail-&gt;prev-&gt;next = temp;
    }
}

void Circular_DLList::print_list()
{
    DLLNode *ptr;
    ptr = tail-&gt;next;
    do {
        cout&lt;&lt; ptr-&gt;info &lt;&lt; endl;
        ptr = ptr-&gt;next;
    }
    while(ptr != tail-&gt;next);
}
</code></pre>

<p>No matter what I write for the delete_from_tail function, it causes a segmentation fault:11. This is my attempt for the function (which throws the error).</p>

<pre><code>int Circular_DLList::delete_from_tail()
{
    int a = tail-&gt;info;
    if(tail == tail-&gt;next) {
        delete tail;
        tail = NULL;
    }
    else {
        tail = tail-&gt;prev;
        delete tail-&gt;next;
        tail-&gt;next = NULL;
    }
    return a;
}
</code></pre>

<p>Any advice as to how to fix this would be fantastic. I've tried debugging but I can't seem to figure out the issue or where exactly it's even related to. 
Thanks</p>