#include
class Foo
{
public:
int add(int a, int b)
{
return a + b;
}
};
int main(void)
{
std::function<int(const Foo&, int, int)> func;
Foo a;
func = &Foo::add;
return 0;
}
这样为什么编译不过, 编译错误消息为
错误 2 error C2664: “void std::_Func_class<_Ret,const Foo &,int,int>::_Set(std::_Func_base<_Ret,const Foo &,int,int> *)”: 无法将参数 1 从“_Myimpl *”转换为“std::_Func_base<_Ret,const Foo &,int,int> *” d:\program files (x86)\microsoft visual studio 12.0\vc\include\functional 506 1
求教大神, 要怎么改?
如果换成这样, 就编译得过
int main(void)
{
std::function<int(Foo, int, int)> func;
Foo a;
func = &Foo::add;
return 0;
}
这是为什么