I am not able to call a pure virtual function of the base class within a lambda of the inherited class. I simplified the problem to the following easy example...
The usecase is, that the class Test
should again be a base class of some other class, that will implement the pure virtual function (anywhere in the program).
class Base
{
public:
virtual void DoSomething(Parameter* p) = 0;
};
class Test : public Base
{
public:
void addFunction()
{
mFunction = [this] (Parameter* p) { Base::DoSomething(p); };
}
private:
std::function<void(Parameter* p)> mFunction;
};
I get following compilation error:
undefined reference to Base::DoSomething(Parameter* p)
My current solution is to call a tempFunction in the base class, and then call the virtual function. But this seems more like a hack... and means unnecessary overhead:
class Base
{
public:
virtual void DoSomething(Parameter* p) = 0;
protected:
void tempDoSomething(Parameter* p) { DoSomething(p); } // call this function instead
};
I am using Android-NDK with clang compiler.