• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ help needed

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?
 
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 *..
 
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).
 
Back
Top