双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

help!什么错误?

rookie001 rookie001 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
template<class T>
int BinaryTree<T>::Insert (const int &value, BinaryNode<T> *& temp){
if(temp==0){temp=new BinaryNode<T> (value);return 1;}
else if(value<temp->data)return Insert(value,temp->left);
else if(value>temp->data)return Insert(value,temp->right);
return 0;
}

//BinaryNode<T> * GetRoot() const{return root;}

main 函数里:
BinaryTree<int> t(1);
for(int i=0;i<4;i++)t.Insert(i,t.GetRoot());

出现错误:error C2664: 'Insert' : cannot convert parameter 2 from 'const class BinaryNode<int> *' to 'class BinaryNode<int> *& '
A reference that is not to 'const' cannot be bound to a non-lvalue
...全文
评论 6
收藏 已收藏
分享
返回顶部
rookie001
C++ 语言 65,214 成员 250,514 内容