I had this problem some time ago and I gave up but lately it returned.
#include <iostream>
class element2D;
class node2D
{
public:
void (element2D::*FunctionPtr)();
void otherMethod()
{ std::cout << "hello" << std::endl;
((this)->*(this->FunctionPtr))(); //ERROR<-------------------
}
};
class element2D
{
public:
node2D myNode;
void doSomething(){ std::cout << "do something" << std::endl; }
};
int main()
{
element2D myElement;
myElement.myNode.FunctionPtr = &element2D::doSomething; //OK
((myElement).*(myElement.myNode.FunctionPtr))(); //OK
return 0;
}
I'm getting error at marked line:
pointer to member type 'void (element2D::)()' incompatible with object type 'node2D'
I would be really thankful for help. There was similar question today which partially helped me: link. But it doesn't seem to be the full answer to my problem.
Actually these two problems have only one difference - point where the function is called.
Thanks for your time