5
struct A
{
void f() {}
};
void f() {}
int main()
{
auto p1 = &f; // ok
auto p2 = f; // ok
auto p3 = &A::f; // ok
//
// error : call to non-static member function
// without an object argument
//
auto p4 = A::f; // Why not ok?
}
为什么我必须使用address-of运算符来获取指向成员函数的指针?为什么我必须使用address-of运算符来获取指向成员函数的指针?
你想在这里做什么?为什么你需要一个成员函数的地址,如果你确实有这样的事情,你会怎么做呢? – tadman
例如'std :: bind(&A :: f,A());' – xmllmx
同时将成员函数传递给'std :: thread'。 –