Hello everyone, I was practicing implementing BSTs from scratch and wrote a "contains" function. The function basically takes in a value and the root and returns true or false when the value is found/not found.
However, when I run it, I'm running into an issue where it says "Problem.cpp(44) : error C2664: 'bool BinarySearchTree::contains(const Node &,int)' : cannot convert argument 1 from 'Node *' to 'const Node &'
Reason: cannot convert from 'Node *' to 'const Node' "
I'm assuming the issue is root.getLeft() and root.getRight() returns a Node * format instead of a const Node.
How would I convert Node * to the const Node format required for my function?
Change lines 44 and 45 to dereference the right and left sides of the root node.
You need to make sure that those pointers are not null before they are dereferenced.