Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function pointer is not a function or function pointer

I have following problem:

void MyClass::LoopFunction(vector<Item>& items,void (MyClass::*funcy)(vector<Item>&,int))
{
    for(SInt32 i = 0; i < 50; i++)
    {
        funcy(items,i);
    }

}

It says:

Called object type 'void(MyClass::*)(vector<Item>&,int)' is not a function or function pointer

Can anyone help me to find a solution for this?

like image 248
jeromintus Avatar asked Jun 17 '15 08:06

jeromintus


1 Answers

funcy is a pointer to a member function, so you need to call it on an instance of the class, like this:

(this->*funcy)(items,i);
like image 126
TartanLlama Avatar answered Sep 28 '22 07:09

TartanLlama