重载的构造函数的调用是不明确的 [英] Call of overloaded constructor is ambiguous

查看:211
本文介绍了重载的构造函数的调用是不明确的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现一个面向对象的二叉树,但是,我得到一个重载的构造函数的调用的错误消息是不明确的。问题是,我真的有必要的构造函数,但C ++似乎不认识它。

I am trying to implement an object-oriented binary tree, however, I get the error message of a call of an overloaded constructor being ambiguous. The problem is that I really do have the necessary constructor, yet C++ doesn't seem to recognize it.

我的代码: http://pastebin.com/PM9PDYAN

错误讯息:

56  36  In constructor 'Node::Node(const int&, Node*, Node*, const int&)':
56  36  [Error] call of overloaded 'Node(const int&, Node* const)' is ambiguous
17  3   [Note] Node::Node(const int&, Node*)
15  3   [Note] Node::Node(const int&, const int&, Node*) <near match>
15  3   [Note] no known conversion for argument 2 from 'Node* const' to 'const int&'
37  1   [Note] Node::Node(const int&, Node*, Node*, Node*)


推荐答案

重叠:

Node(const int&, Node* = nullptr, Node* = nullptr, Node* = nullptr);

和:

Node(const int&, Node* = nullptr);

这两个都可以匹配只有 int 或只是 int 节点*

Both of these could match a call with just an int or just an int and a Node *.

看起来还有其他重叠的构造函数。

Looks like there are other overlapping constructors as well.

这篇关于重载的构造函数的调用是不明确的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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