C++ 11 Thread initialization with member functions compiling error [duplicate]

我只是一个虾纸丫 提交于 2019-11-30 05:14:40

You need a callable object taking no parameters, so

thread t3(&A::foo, &obj);

should do the trick. This has the effect of creating a callable entity which calls A::foo on obj.

The reason is that a non-static member function of A takes an implicit first parameter of type (possibly cv qualified) A*. When you call obj.foo() you are effectively calling A::foo(&obj). Once you know that, the above incantation makes perfect sense.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!