lundi 8 octobre 2018

can not access memory at address 0xc8

I am writing a code to return data of a node in BST based on id. below is my node class:

struct Node{
int id;
string data;
Node *left;
Node *right;
Node();
};

below is my getEntry class:

string BST::getEntry(Node *base,int id) {
if (base == nullptr){
    return "";
}
if (base->id == id){
    cout<<base->data<<endl;
    return base->data;
}
if (base->id != id){
    getEntry(base->left,id);
    getEntry(base->right,id);
}
}

The code would compile but does not return anything, I tried to debug, at the "return base->data statement", there is an error "can not access memory at address 0xc8". What causes the problem and what can I do about it?

Aucun commentaire:

Enregistrer un commentaire