Error while running erase function in hashmap

#include <stdio.h>
void erase(string key){

int idx=hashfunc(key);

Node<T>*temp=table[idx];

while(temp!=NULL){

if(temp->key==key){

    table[idx]=temp->next;

    delete temp;

    return;

}

else{

    temp=temp->next;

}

}

}