我正在尝试将某些类方法传递给某个函数并出现“函数调用缺少参数列表;使用 '& ' 创建指向成员的指针”错误。
//There is some class
class A {
int someField;
void Add(int someAdd) {
someField += someAdd;
}
}
//And function
void someFunc(std::function<void(int x)> handler) {
//Some code
handler(234);
}
//Class method pass to function
void main() {
A* instanceA = new A();
someFunc(instanceA->Add); //Error 19 error C3867: 'A::Add': function call missing argument list; use '&A::Add' to create a pointer to member
}
怎么了?