编译器添加引用运算符

时间:2014-03-28 13:31:26

标签: c++ reference

我尝试从另一个类调用一个类函数,我得到了一些非常奇怪的东西

所有参数都被视为引用,我不明白为什么编译器将此作为特殊情况威胁

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*>*)

以下是来自调用类

的objjects指针
class IdentifyCandidateMatchingTerm : public FOLVisitor 
{
private:
    FOLTerm* toMatch;
    vector<FOLVariable>* toMatchVariables;
    FOLTerm* matchingTerm;
    unordered_map<FOLVariable, FOLTerm*>* substitution;

请帮帮我,这真的很奇怪......

1 个答案:

答案 0 :(得分:3)

您已使用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>*
                                             ^^^^^^^^

这清楚地解释了发生了什么。仔细检查您调用此方法的方式和位置。

相关问题