user1896802
user1896802

Reputation: 1

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?

Upvotes: 0

Views: 3424

Answers (1)

perreal
perreal

Reputation: 97918

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.

Upvotes: 1

Related Questions