C++ help needed

duragezic

Lifer
Oct 11, 1999
11,234
4
81
Hmph, I keep getting this error whenever I attempt to have a return type of BTNode*. Class BTNode is declared in my header file. I've been working on several binary tree functions but when I write a function that requires a BTNode* return type, I always get this error.

The error line is at BTNode* Tree::contains( BTNode* node, int k ) line in the code below. That function is invoked by: return remove( contains(root, k) );

I need that contains() function to return a BTNode* since that is passed to the remove function as a argument, thus the remove function knows the location of the node to delete. It also doubles as a bool for contains().

Any ideas?
 

itachi

Senior member
Aug 17, 2004
390
0
0
where's BTNode declared?

if it's declared in Tree.. you have to do BTNode::Tree * Tree::contains(BTNode * node, int k)

edit: whoops.. i meant Tree::BTNode * not BTNode::Tree *..
 

duragezic

Lifer
Oct 11, 1999
11,234
4
81
I updated the OP with Tree.h.

edit: Oops I think I mis-interepted what you said at first. So, what you mean is change the function signature line in my Tree.C from

BTNode* contains( BTNode* node, int k ) { ... }

TO

Tree::BTNode* Tree::contains( BTNode* node, int k ) { ... }'

?

Or does that apply to the definition of contains() (under /* private helper functions */) as well as where I actually do the implementation?

I'll try that out tomorrow when I'm back at school on the lab machines (didn't get a chance to get a compiler yet for home machine).