Erase function of HashTable not woking

Why is the erase function not working for the given code? https://ide.codingblocks.com/s/213179 It works when called for the first time only.The second time it does not work.Please provide the corrected code

@Codarikh
The problem was occuring because of your node destructor. When a node is deleted , it goes to delete the entire linked list in front of it as well. We need to move around some pointers in erase function to prevent other elements from getting deleted.
Modified erase function -


void erase(string key){
        int idx=hashfn(key);
        node*ptr=table[idx];
        if(ptr->key==key){
            table[idx]=ptr->next;
            ptr->next = NULL;
            delete (ptr);
            curr_size--;
            return;
        }
        while(ptr->next!=NULL){
            if(ptr->next->key==key){
                node*temp=ptr->next;
                ptr->next=temp->next;
                temp->next = NULL;
                delete (temp);
                return;
            }
            ptr=ptr->next;
        }
        return;
    }