Question

I currently have something like this

void asomeMethod(int q)
{
    std::cout << "Method with parameter " << q ;
}

int main()
{
     boost::function<void(int)> parfunct;
     parfunct = boost::bind(&asomeMethod,12);
     parfunct;  //Does not call asomeMethod ??
    return 0;
}

I want to call the function ptr but the method is not being called ? Any suggestions on what I might be doing wrong ?

Was it helpful?

Solution

It has to be boost::function<void()>, since there's no remaining argument.

Then call it like a function:

parfunct();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top