c++ – No Matching Function – Specialized Signature hiding Generic? – Education Career Blog

I just got stuck with the following C++ compiler error:

no matching function for call "EPTDerivedException::HandleClass( BaseClass& )"
candidates are: void EPTDerivedException::HandleClass( DerivedClass )

I cannot explain this, because there should be a function HandleClass( BaseClass ). This is the calling code:

BaseClass oBase;
EPTDerivedException* pException2 = new EPTDerivedException;
pException2->HandleClass( oBase );

And this is the code for EPTDerivedException:

class EPTDerivedException : public EPTException
{
public:
    EPTDerivedException();
    // generic function
    void HandleClass( DerivedClass oClass ) { Q_UNUSED(oClass); }
};

And for the base class:

class EPTException
{
public:
    EPTException( QString strName );
    // specialized function
    void HandleClass( BaseClass oBase ) { Q_UNUSED(oBase); }
private:
    QString m_strName;
};

The strange things is also, that when I recompile (make clean; make) the code, I get the error message. If I add a space ” ” in the calling code (main.cpp) – the compiling afterwards is successful – and I have no idea why…

Thanks a lot,

Charly

PS: I use gcc 4.4.5 with Debian Squeeze, the qt-creator as IDE with qt 4.6 – but this problem is independent from Qt.

,

I’m not sure why you think there should be a EPTDerivedException::HandleClass( BaseClass oBase ) function. There’s no such declaration.

Perhaps you need to add using EPTException::HandleClass; to EPTDerivedException ?

Leave a Comment