Here's the prototype of the function:
void BinaryDimonTree::insert(int x, int y, int level, TreeNode *&cur)
in the function, I tried to call:
insert(x, y, ++level, cur->getLeftChild());
and here's getLeftChild
:
TreeNode* TreeNode::getLeftChild() const {
return this->left;
}
Then, it reports an error:
no instance of overloaded function "BinaryDimonTree::insert" matches the argument list -- argument types are: (int, int, int, TreeNode *)
If I change my code this way:
TreeNode *child = cur->getLeftChild();
insert(x, y, ++level, child);
No error would be reported.
I wonder why this problem occurs and how to solve it if I want to directly use the function return value as the parameter?
Thanks a lot!