类型为“节点*"的参数与"BinarySearchTree *"类型的参数不兼容; [英] argument of type "Node *" is incompatible with parameter of type "BinarySearchTree *"

查看:175
本文介绍了类型为“节点*"的参数与"BinarySearchTree *"类型的参数不兼容;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 how can i handle this error
argument of type "Node<int> *" is incompatible with parameter of type "BinarySearchTree<int> *"

推荐答案

您没有给我们很多代码来工作-仅一个线-但我认为您已经将自己描绘在一个角落.

我认为是binTree被声明为BST *,而root被删除为Node *-您在注释中暗示了尽可能多的内容,因此您不能为binTree分配root值,因为节点不是BST.


如果要设计二叉树,则通常将诸如Root,Next和Previous之类的节点声明为BST *,而不是将其声明为单独的类-否则到达那里时,您不能将它们视为BST.

我无法提供具体的代码来修复它-我无法读取您的HDD或看到您的屏幕-但请查看您如何定义事物,看看是否可以发现逻辑问题! :laugh:
You don''t give us a lot of code to work with - just the one line - but I think you have painted yourself into a corner.

What I think is that binTree is declared as BST*, and root is delcared as Node* - you imply as much in your comments, so you can''t assign a root value to binTree because a Node is not a BST.


If you are designing a binary tree, then normally the nodes such as Root, Next, and Previous are declared as BST* not as separate a separate class - otherwise you can''t treat them as BST''s when you get there.

I can''t give you concrete code to fix it - I can''t read your HDD or see your screen - but look at how you have defined things, and see if you can spot the logical problem! :laugh:


嘿,我自己找到了解决方案,实际上我将Node * root声明为私有成员,这就是为什么我无法在其他类中访问它的原因.
hey i found its solution by myself actually i declared Node* root as private member that''s why i can''t access it in other class.


这篇关于类型为“节点*"的参数与"BinarySearchTree *"类型的参数不兼容;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆