我试着从另一个类调用一个类函数,我得到一些非常奇怪的东西
所有参数都被视为引用,我不明白为什么编译器会将其视为特例
class AbstractModulation
{
public:
virtual bool isValidMatch(
FOLTerm* toMatch,
std::set<FOLVariable>* toMatchVariables,
FOLTerm* possibleMatch,
unordered_map<FOLVariable, FOLTerm*>* substitution)=0;
...
这条线:
abstractModulation->isValidMatch(toMatch, toMatchVariables,(FOLTerm*) variable,substitution)
导致此错误(参见&字符添加到每个参数..wtf?):
AbstractModulation.cpp:105:104: error: no matching function for call to ‘AbstractModulation::isValidMatch(FOLTerm*&, std::vector<FOLVariable>*&, FOLTerm*, std::unordered_map<FOLVariable, FOLTerm*>*&)’
候选人:
AbstractModulation.h:44:7: note: bool AbstractModulation::isValidMatch(FOLTerm*, std::set<FOLVariable>*, FOLTerm*, std::unordered_map<FOLVariable, FOLTerm*>*)
,这里是调用类
的对象指针class IdentifyCandidateMatchingTerm : public FOLVisitor
{
private:
FOLTerm* toMatch;
vector<FOLVariable>* toMatchVariables;
FOLTerm* matchingTerm;
unordered_map<FOLVariable, FOLTerm*>* substitution;
请帮帮我,这真的很奇怪…
您已经定义了使用std::set<FOLVariable>*
变量的函数,但您试图用std::vector<FOLVariable>*
调用它。
error: no matching function for call to
‘AbstractModulation::isValidMatch(FOLTerm*&, std::vector<FOLVariable>*&,
^^^^^^^^^^^
但是定义是
virtual bool isValidMatch( FOLTerm* toMatch, std::set<FOLVariable>*
^^^^^^^^
这清楚地解释了发生了什么。请仔细检查如何以及在何处调用此方法。