g++ complains about
myclass.cxx:185: error: no matching function for call to 'IMyInterface::doSomething(const SomeClass*, unsigned int)'
IMyInterface.h:34: note: candidates are: virtual void IMyInterface::doSomething(const SomeClass*&, unsigned int)
when I call
m_instanceOfInterface->doSomething((const SomeClass*)0,(unsigned int)1);
Any pointers to why? It seems to me that g++ is seeing exactly the same signature between what is declared and what is being called, but still complains about no matching function found.
I can call, in the same context, another function of IMyInteface, IMyInterface::doSomethingElse(float& p). So somehow the const is the problem?
I did not pass the NULL pointer and cast a constant integer just for fun… originally I have
m_instanceOfInterface->doSomething((const SomeClass*)m_someDerivedClass,m_anInteger);
and got the same error. So I decided to clarify things with g++ by giving some explicit arguments. I can assure you that the NULL pointer is NOT the problem – although understandably we all cringed a bit when seeing a NULL being passed with const 🙂
The function requires its argument by non-const reference, which cannot bind to a temporary. Observe:
In your case,
T = SomeClass const *. So, you have provide a non-temporary:Note that the purpose of this is presumably to fill
pcwith some meaningful value, so be sure to incorporate that apporpriately.