#include <iostream>
usingnamespace std;
class A
{
void foo()
{
cout << "Arrived foo" << endl;
}
void test();
};
void baa( auto (A::*pointer_func) ())
{
(this->*pointer_func)(); // throws an error here
}
void A::test()
{
baa(foo);
}
int main()
{
}
I am trying to call the member function 'foo' from the non-member function 'baa' but it throws me this error
|18|error: invalid use of 'this' in non-member function|
I understand this error as it is pretty straightforward, but I just don't know how to fix it. If I can not use 'this' in non-member function then can use something else to achieve this goal?