【发布时间】:2014-12-08 12:25:39
【问题描述】:
我有一个.h 文件,其中包含
template <typename DataType>
class BST
{
private:
struct BinaryNode
{
//variables
}
public:
BinaryNode *root;
int contains(const DataType &x, BinaryNode *&t) const;
}
我正在尝试从以下地址致电contains:
void SequenceMap::merge(BST<SequenceMap> theMap)
{
theMap.contains(this, theMap.root);
}
contains的实现是
template <typename DataType>int BST<DataType>::contains(const DataType &x, BST<DataType>::BinaryNode *&t) const
{
//some stuff
}
我遇到了它所说的问题:no matching function call to BST<SequenceMap>::contains(SequenceMap* const, BST<SequenceMap>::BinaryNode*&)theMap.contains(this,theMap.root)
我不确定这其中的哪一部分是错误的,因为this 是Datatype 的变量SequenceMap 而theMap.root 是BinaryNode。我尝试将其更改为*theMap.root,但这没有帮助。
【问题讨论】:
-
BST<SequenceMap>BST的模板声明在哪里?你真的错过了template <typename T>class BST { // ... -
@πάνταῥεῖ 实际上 jaba10 只是添加了代码突出显示并大写了一些东西。我是在 BST 上方添加模板声明的人,如修订版 2 所示。
-
在公共方法接口中使用私有类型不是很好...
-
好吧,那你说清楚了。