当我编译下面的一段代码时,出现以下错误。任何人都可以帮助我解决这个问题。谢谢。指向成员函数错误
错误:ISO C++禁止将绑定成员函数的地址形成指向成员函数的指针。说“& FOO :: ABC” [-fpermissive]
升压::螺纹testThread(升压::绑定(& f.abc中,f));
............................................. ............................................. ...........................^
#include <iostream>
#include <boost/asio.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
class foo
{
private:
public:
foo(){}
void abc()
{
std::cout << "abc" << std::endl;
}
};
int main()
{
foo f;
boost::thread testThread(&f.abc, f);
return 0;
}
即使在拆除类动物园后,我收到了同样的错误。 – shaikh
@shaikh什么错误?所有这些选项[为我工作](http://coliru.stacked-crooked.com/a/93c8f533b7c466f5) – Praetorian
住它的工作正常。我不知道为什么我得到一个长的错误信息。 thread.cpp :(。text + 0x74):对boost :: thread :: join()的未定义引用。 thread.cpp在函数中使用'__static_initialization_and_destruction_0(int,int)':'(')' thread.cpp :(。text + 0x95):未定义的引用'boost :: thread ::〜thread()' /tmp/ccAzOPoD.o: (.text + 0xf4):未定义的引用boost :: system :: generic_category()' thread.cpp :(。text + 0xfe):未定义的引用'boost :: system :: generic_category()' )' ... collect2:错误:ld返回1退出状态 – shaikh