samedi 3 septembre 2022

C++ How to solve "no matching function for call" in class with template [closed]

I have a class called Thingy which has a member function dosomething which takes another Thingy as input. I can't figure out why I can't invoke the function. I'm sure its something dumb I've done but I can't see it. Using C++11

In thingy.h I have:

template<typename T>
class Thingy {
    ...

    /**
     * Returns the result as a new instance
     */
    Thingy<T> dosomething(const Thingy<T>& thing) const {
        return dosomething(thing, DEFAULT_THRESHOLD);
    }

    /**
     * Returns the result as a new object
     */
    Thingy<T> dosomething(const Thingy<T>& thing, const unsigned threshold) const {
    ...
    }
}

Appreciate any help, thank you!

p01core.cc:82:144:   required from here
p01core.cc:65:34: error: no matching function for call to ‘Thingy<int>::dosomething(Thingy<int>*, unsigned int&)’
                     result= thing1.dosomething(&thing2, threshold);
In file included from p01core.h:16,
                 from p01core.cc:9:
thingy.h:164:19: note: candidate: ‘Thingy<T> Thingy<T>::dosomething(const Thingy<T>&) const [with T = int]’
         Thingy<T> dosomething(const Thingy<T>& B) const {
                   ^~~~~
thingy.h:164:19: note:   candidate expects 1 argument, 2 provided
thingy.h:171:19: note: candidate: ‘Thingy<T> Thingy<T>::dosomething(const Thingy<T>&, unsigned int) const [with T = int]’
         Thingy<T> dosomething(const Thingy<T>& thing, const unsigned threshold) const {
                   ^~~~~

Aucun commentaire:

Enregistrer un commentaire