【发布时间】:2018-04-04 19:22:22
【问题描述】:
我创建了一个具有收集数据功能的模板化 BST:
typedef void (*func)(T&);
...
template<class T>
void BST<T>::inorderCollectionTraversal(func f) const
{
inorderCollection(root,f);
}
template<class T>
void BST<T>::inorderCollection(node<T> *p, func f) const
{
if(p!=NULL){
inorderCollection(p->leftPtr, f);
f(p->data);
inorderCollection(p->rightPtr, f);
}
}
然后在另一个类中,我尝试使用这个数据结构对另一个类的对象进行排序。我无法从 BST 中提取对象:
map<string, BST<Weather> > dataByMonth;
dataByMonth.find(monthCount[i]+eYear)->second.inorderCollectionTraversal(collectData); // the error points to this line
void Query::collectData(Weather& w){
collector.push_back(w);
}
其他一切都经过测试,没有问题。只有这样是行不通的。错误信息是:
没有匹配函数调用 'BST谁能告诉我哪里出错了?
【问题讨论】:
-
欢迎来到 Stack Overflow!请将您的问题editminimal reproducible example 或SSCCE (Short, Self Contained, Correct Example)
-
看起来有东西试图调用
BST::inorderCollectionTraversal(),它没有给出任何参数,并且不存在。
标签: c++