Errors in BST

I don't understand the errors that I get. Here is the code where it is having trouble:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void BinarySearchTree::findElement(struct tree_node* node, int d)
{
	if (node==NULL)
        {
		cout<<"Element not found!\n";
        }
	
        else
	{
		if (d == node->data)
                {
                    cout<<"Element found\n";
                }
			//findElement(d,p->left);
		else 
                {
                    if(d < node->data)
                    {
                        cout<<"Element Found !";
                       
                        // return(findElement(node->left,d));
                    }
                    else return(findElement(node->right, d));
                    cout<<"Element Found !";
                }        	
	}
}


Here is what I have in main:
b.findElement(node,z);
My error is in here under node

Here is what I have under public:
void findElement(struct tree_node* node,int);

Let me know what you suggest. I'm just going round and round in circles.

Thanks

use b.findElement(&node,z), it will provide the pointer to your function.
Last edited on
Thanks! It didn't quite work though. Now I get this error:

bst.cpp:261: error: 'node' was not declared in this scope
Topic archived. No new replies allowed.