say I have this program situation overhere:
struct A
{
int(*func_ptr)();
};
struct B
{
int b = 0;
void SetFunctionPointerToLambda(A& a)
{
a.func_ptr = [=] () { return b; };
}
};
int main()
{
A a;
B b;
b.SetFunctionPointerToLambda(a);
}
I want to set a function pointer of an object A to a lambda, which is based of the values of an object B. So, how is this going to be done?
Current error message:
loeschen5.cc: In member function 'void B::SetFunctionPointerToLambda(A&)':
loeschen5.cc:14:41: error: cannot convert 'B::SetFunctionPointerToLambda(A&)::<lambda()>' to 'int (*)()' in assignment
a.func_ptr = [=] () { return b; };
^
Thanks for any help!