为什么要使用成员函数呢?为了使用成员变量啊。

具体代码:

#include <thread>

class Test
{
public:
    void thread_loop();

    Test()
    {
        std::thread t(&Test::thread_loop, this);
        t.detach();
    }
}

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐