I'm trying to implement Doubly Lined List with tail and head.
Could you show me where i have made a mistake
All code on GitHub here : https://github.com/ZSzymon/Circual-Double-Linked-List
I'm thinking that the problem is destructor
ListV2::~ListV2()
{
    Node *current = head;
    Node *nextNode;
    while(current->next)
    {
        nextNode = current->next;
        delete current;
        current = nextNode;
    }
}
Taking your advice i changed destructor into this:
ListV2::~ListV2()
{
    Node *nextNode;
    while(head)
    {
        nextNode = head;
        head = head->next;
        delete nextNode;
    }
}
Tried some debugging. Got this error "The inferior stopped because it triggered an exception. Stopped in thread 0 by: Exception at 0x9a3848, code: 0xc0000005: read access violation at: 0xfffffffffeeefef2, flags=0x0 (first chance)."
This is Node struct
struct Node
{
    std::string data;
    Node *next;
    Node *prev;
    Node(std::string data):data(data)
    {
        next=nullptr;
        prev=nullptr;
    }
};
The program is crushing while delete myList;
User contributions licensed under CC BY-SA 3.0