I've encountered a strange case when the final
keyword is added to a virtual function declaration, with its definition on a separate .cpp file.
Consider the following example:
IClass.hpp
class IClass //COM-like base interface
{
protected:
virtual ~IClass(){} //derived classes override this
public:
virtual void release() final;
};
dllmain.cpp (shared library)
#include "IClass.hpp"
...
void IClass::release()
{
delete this;
}
...
main.cpp (standalone executable)
//various includes here
...
int main(int argc, char** argv)
{
/* From "IGameEngine.hpp"
class IGameEngine : public IClass
{
...
};
*/
IGameEngine* engine = factoryGameEngine();
...
engine->release();
return 0;
}
As it is, GCC 4.9.2 will report an undefined reference to 'IClass::release()'
My goal is to have IClass::release()
as non-overridable while having its implementation hidden inside the game engine's shared library.
Any suggestions?