#include <functional>
struct A
{
int func(int x, int y)
{
return x+y;
}
};
int main()
{
typedef std::function<int(int, int) > Funcp;
A a;
//Funcp func = std:::bind(&A::func, &a);
Funcp func = std::bind(&A::func, a, std::placeholders::_1);
return 0;
}
我在上述两个绑定(bind)函数中都遇到了错误:
error C2825: '_Fty': must be a class or namespace when followed by '::'
语法错误在哪里?我正在使用 Visual Studio 2010
最佳答案
Funcp func =
std::bind(&A::func, &a, std::placeholders::_1, std::placeholders::_2);
关于c++ - std::function 到成员函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5154116/