简体   繁体   中英

binary tree inorder traversal in C++

I'm trying to print out a binary tree I've build using inorder traversal, but I'm having trouble on defining how to pass values to the recursive function. Here is the error I'm getting:

1>methods.obj : error LNK2001: unresolved external symbol "public: void __thiscall morsecode::in_order(struct letter *)" (?in_order@morsecode@@QAEXPAUletter@@@Z)

Here's my tree from my header file:

struct letter
{
    string let;
    string morse;
    letter *left;
    letter *right;
};

Method from source file:

void in_order(struct letter *P)
    {
        if(P==NULL) return;
        in_order(P->left);
        cout<<"letter: "<<P->let<<endl;
        in_order(P->right);
    }

Am I missing something important here?

Perhaps you need:

void morsecode::in_order(struct letter *P) {
     if(P==NULL) return;
     in_order(P->left);
     cout<<"letter: "<<P->let<<endl;
     in_order(P->right);
}

to be a member of the morsecode class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM