SemicolonExpected
SemicolonExpected

Reputation: 614

No matching function for call

I have a .h file containing

template <typename DataType>
class BST
{
private:
    struct BinaryNode
    {
         //variables
    }
public:
    BinaryNode *root;

    int contains(const DataType &x, BinaryNode *&t) const;
}

I'm trying to call contains from:

void SequenceMap::merge(BST<SequenceMap> theMap)
{
    theMap.contains(this, theMap.root);
}

The implementation of contains is

template <typename DataType>int BST<DataType>::contains(const DataType &x, BST<DataType>::BinaryNode *&t) const
{
 //some stuff
}

I'm having the issue that it's saying: no matching function call to BST<SequenceMap>::contains(SequenceMap* const, BST<SequenceMap>::BinaryNode*&) at theMap.contains(this,theMap.root)

I'm not sure what part of this is wrong as this is a variable of Datatype SequenceMap and theMap.root is a BinaryNode. I have tried changing it to *theMap.root but that does not help.

Upvotes: 0

Views: 299

Answers (1)

iwolf
iwolf

Reputation: 1062

The function calls for x by reference, not by pointer. You probably want:

theMap.contains(*this, theMap.root);

Upvotes: 3

Related Questions