Class B
{
public:
void fun(int i){}
};
typedef std::function<void(int)> fPtr;
class C
{
public:
void fun1(fptr handle){}
};
class A
{
public:
B object;
C object1;
void temp()
{
object1.fun1(&B::fun);
}
};
我试图将fun1()调用为给定,但它给出了编译器错误。什么是正确的称呼方式?
答案 0 :(得分:1)
据推测,您想要打电话:
object1.fun1([this](int n){object.fun(n);});
可替换地:
object1.fun1(std::bind(&B::fun, &object, std::placeholders::_1));