【发布时间】:2019-09-05 10:24:58
【问题描述】:
这是函数的原型:
void BinaryDimonTree::insert(int x, int y, int level, TreeNode *&cur)
在函数中,我尝试调用:
insert(x, y, ++level, cur->getLeftChild());
这里是getLeftChild:
TreeNode* TreeNode::getLeftChild() const {
return this->left;
}
然后报错:
重载函数“BinaryDimonTree::insert”的实例与参数列表不匹配——参数类型为:(int, int, int, TreeNode *)
如果我这样更改代码:
TreeNode *child = cur->getLeftChild();
insert(x, y, ++level, child);
不会报告错误。
不知道为什么会出现这个问题,如果我想直接使用函数返回值作为参数怎么解决?
非常感谢!
【问题讨论】:
-
您不能使用隐式 temp 作为参考参数。通话后您会如何提及它?
标签: c++ pointers data-structures function-parameter